Repository navigation
Description
Current behavior
- In tests, the reranker points at the real dev endpoint ([test-reranking-providers-config.yaml#L15](), loaded in [DseTestResource.java#L131](
url: https://us-west-2.api-dev.ai.datastax.com/nvidia/v1/ranking )). CI can't call that endpoint.data-api/src/test/java/io/stargate/sgv2/jsonapi/testresource/DseTestResource.java
Line 131 in 02d0423
propsBuilder.put("RERANKING_CONFIG_RESOURCE", "test-reranking-providers-config.yaml"); - So no existing test ever completes a rerank:
- every findAndRerank IT only checks errors ([FindAndRerankCollectionIntegrationTest.java](https://github.com/stargate/data-api/blob/02d0423347cb2c382c9b7535903a54d2c5e143f6/src/test/java/io/stargate/sgv2/jsonapi/api/v1/FindAndRerankCollectionIntegrationTest.java));
- the MCP IT avoids the reranker on purpose. It uses a
rerankOnfield that doesn't exist, so all documents are dropped before reranking ([CollectionCommandToolsMcpIntegrationTest.java#L193-L212]()).Lines 193 to 212 in 02d0423
void testFindAndRerankToolCall() { callToolAndAssert( CommandName.Names.FIND_AND_RERANK, Map.of( "keyspace", keyspaceName, "collection", collectionName, "sort", Map.of("$hybrid", Map.of("$vector", List.of(0.25, 0.25, 0.25, 0.25, 0.25))), "options", Map.of("rerankQuery", "I like cheese", "rerankOn", "content")), assertDataOnly( data -> { // Use an inexistent field "content" in rerankOn, so it will not do the actual rerank // operation(cannot call reranker) and return an empty result JsonArray docs = data.getJsonArray("documents"); assertNotNull(docs); assertEquals(0, docs.size()); }));
DataApiResponseValidator.wasSuccessful()doesn't supportfindAndRerankyet ([DataApiResponseValidator.java#L74-L76]()).data-api/src/test/java/io/stargate/sgv2/jsonapi/api/v1/util/DataApiResponseValidator.java
Lines 74 to 76 in 02d0423
default -> throw new IllegalArgumentException( "DataApiResponseValidator: Unexpected command name: " + commandName);
Why fix it
- We can't test the core of the feature: result order, how many candidates each leg reads, and the default rerank query and passage.
Implementation and acceptance criteria
Add a separate successful-reranking test PR before the two #2599 implementation PRs. Use class-scoped, dynamic-port WireMock URLs with the production Nvidia HTTP client. Scores must depend on passage content rather than concurrent batch arrival, and provider responses must include rankings[].logit.
Exercise existing $hybrid requests and the local embedding test provider. Cover default and explicit queries/passages, final ordering, projection, result limits, optional scores, hybrid deduplication, batching, and zero provider calls when no usable candidates remain. Extend DataApiResponseValidator.wasSuccessful() and replace the MCP missing-field workaround with successful reranking of existing documents.
Seed 60 unique passages, assert every passage reaches the HTTP reranker exactly once, and give a candidate beyond position 50 the highest score. Add database-free HTTP client coverage for serialization, headers, batch indices, response decoding, and usage. Packaged integration tests run in the existing DSE/HCD CI matrix, with lexical cases gated to HCD.
Public single-leg request syntax is outside this PR.
Draft PRs
PR #2605 adds the successful HTTP/MCP coverage. It is the first draft in the stack followed by #2606 and #2607.
Activity