Skip to content
Framework Docs

Retrieve

RetrievalRetrieveResponse beta().retrieval().retrieve(RetrievalRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/api/v1/retrieval/retrieve

Retrieve relevant chunks via hybrid search (vector + full-text), with filtering on built-in or user-defined metadata.

ParametersExpand Collapse
RetrievalRetrieveParams params
Optional<String> organizationId
Optional<String> projectId
String indexId

ID of the index to retrieve against.

String query

Natural-language query to retrieve relevant chunks.

Optional<CustomFilters> customFilters

Filters on user-defined metadata fields.

class FilterTypeUnionStrIntBoolFloat:
Operator operator
One of the following:
EQ("eq")
NE("ne")
GT("gt")
LT("lt")
GTE("gte")
LTE("lte")
IN("in")
NIN("nin")
Value value
One of the following:
String
boolean
double
List<UnnamedSchemaWithArrayParent1>
One of the following:
String
boolean
double
List<FilterTypeUnionIntFloat>
Operator operator
One of the following:
EQ("eq")
NE("ne")
GT("gt")
LT("lt")
GTE("gte")
LTE("lte")
IN("in")
NIN("nin")
Value value
One of the following:
double
List<double>
Optional<Double> fullTextPipelineWeight

Weight of the full-text search pipeline (0-1).

Optional<Long> numCandidates

Number of candidates for approximate nearest neighbor search.

Optional<Rerank> rerank

Reranking configuration applied after hybrid search. Enabled by default.

Optional<Boolean> enabled

Set to false to disable reranking.

Optional<Long> topN

Number of results to return after reranking.

Optional<Double> scoreThreshold

Minimum score threshold for returned results.

Optional<StaticFilters> staticFilters

Filters on built-in document fields (page range, chunk index, etc.).

Optional<ParsedDirectoryFileId> parsedDirectoryFileId
Operator operator
One of the following:
EQ("eq")
NE("ne")
GT("gt")
LT("lt")
GTE("gte")
LTE("lte")
IN("in")
NIN("nin")
Value value
One of the following:
String
List<String>
Optional<Long> topK

Maximum number of results to return.

Optional<Double> vectorPipelineWeight

Weight of the vector search pipeline (0-1).

ReturnsExpand Collapse
class RetrievalRetrieveResponse:

Response containing retrieval results.

List<Result> results

Ordered list of retrieved chunks.

String content

Text content of the retrieved chunk.

Optional<Metadata> metadata

User-defined metadata associated with the chunk.

One of the following:
String
long
double
boolean
JsonValue;
List<String>
Optional<Double> rerankScore

Relevance score from the reranker, if reranking was applied.

Optional<Double> score

Hybrid search relevance score.

Optional<StaticFields> staticFields

Built-in fields stored for every exported chunk.

Optional<List<Attachment>> attachments

Attachments associated with the chunk

String attachmentName

Attachment-relative path, e.g. ‘screenshots/page_7.jpg’.

String sourceId

File ID to pass as source_id when fetching the attachment.

String type

Attachment kind, e.g. ‘screenshot’, ‘items’.

Optional<Long> chunkEndChar

End character offset of the chunk.

Optional<Long> chunkIndex

Index of the chunk within the file.

Optional<Long> chunkStartChar

Start character offset of the chunk.

Optional<Long> chunkTokenCount

Token count of the chunk.

Optional<Long> pageRangeEnd

Last page number covered by this chunk.

Optional<Long> pageRangeStart

First page number covered by this chunk.

Optional<String> parsedDirectoryFileId

ID of the parsed file.

Retrieve

package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.beta.retrieval.RetrievalRetrieveParams;
import com.llamacloud_prod.api.models.beta.retrieval.RetrievalRetrieveResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        RetrievalRetrieveParams params = RetrievalRetrieveParams.builder()
            .indexId("idx-abc123")
            .query("What are the key findings?")
            .build();
        RetrievalRetrieveResponse retrieval = client.beta().retrieval().retrieve(params);
    }
}
{
  "results": [
    {
      "content": "content",
      "metadata": {
        "foo": "string"
      },
      "rerank_score": 0,
      "score": 0,
      "static_fields": {
        "attachments": [
          {
            "attachment_name": "attachment_name",
            "source_id": "source_id",
            "type": "type"
          }
        ],
        "chunk_end_char": 0,
        "chunk_index": 0,
        "chunk_start_char": 0,
        "chunk_token_count": 0,
        "page_range_end": 0,
        "page_range_start": 0,
        "parsed_directory_file_id": "parsed_directory_file_id"
      }
    }
  ]
}
Returns Examples
{
  "results": [
    {
      "content": "content",
      "metadata": {
        "foo": "string"
      },
      "rerank_score": 0,
      "score": 0,
      "static_fields": {
        "attachments": [
          {
            "attachment_name": "attachment_name",
            "source_id": "source_id",
            "type": "type"
          }
        ],
        "chunk_end_char": 0,
        "chunk_index": 0,
        "chunk_start_char": 0,
        "chunk_token_count": 0,
        "page_range_end": 0,
        "page_range_start": 0,
        "parsed_directory_file_id": "parsed_directory_file_id"
      }
    }
  ]
}