Skip to content

FARR requires includeScores #61

@skedwards88

Description

@skedwards88

The example below errors unless I add .includeScores(true). .includeScores(false) or omitting includeScores errors:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.6.2:java (default-cli) on project find-and-rerank-vectorize-lexical-java: An exception occurred while executing the Java class. Cannot invoke "com.datastax.astra.internal.api.DataAPIStatus.getDocumentResponses()" because the return value of "com.datastax.astra.internal.api.DataAPIResponse.getStatus()" is null -> [Help 1]
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.Collection;
import com.datastax.astra.client.collections.commands.cursor.CollectionFindAndRerankCursor;
import com.datastax.astra.client.collections.commands.options.CollectionFindAndRerankOptions;
import com.datastax.astra.client.collections.definition.documents.Document;
import com.datastax.astra.client.core.hybrid.Hybrid;
import com.datastax.astra.client.core.query.Sort;
import com.datastax.astra.client.core.rerank.RerankedResult;

public class Example {

  public static void main(String[] args) {
    // Get an existing collection
    Collection<Document> collection =
        new DataAPIClient("APPLICATION_TOKEN")
            .getDatabase("API_ENDPOINT")
            .getCollection("COLLECTION_NAME");

    // Find documents
    Hybrid hybrid = new Hybrid().vectorize("A house in the woods").lexical("house hill grassy");
    CollectionFindAndRerankCursor<Document, Document> cursor =
        collection.findAndRerank(new CollectionFindAndRerankOptions().sort(Sort.hybrid(hybrid)));

    // Iterate over the results
    for (RerankedResult<Document> result : cursor) {
      System.out.println(result.getDocument());
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions