# Retrieval ## 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. ### Parameters - `RetrievalRetrieveParams params` - `Optional organizationId` - `Optional projectId` - `String indexId` ID of the index to retrieve against. - `String query` Natural-language query to retrieve relevant chunks. - `Optional customFilters` Filters on user-defined metadata fields. - `class FilterTypeUnionStrIntBoolFloat:` - `Operator operator` - `EQ("eq")` - `NE("ne")` - `GT("gt")` - `LT("lt")` - `GTE("gte")` - `LTE("lte")` - `IN("in")` - `NIN("nin")` - `Value value` - `String` - `boolean` - `double` - `List` - `String` - `boolean` - `double` - `List` - `Operator operator` - `EQ("eq")` - `NE("ne")` - `GT("gt")` - `LT("lt")` - `GTE("gte")` - `LTE("lte")` - `IN("in")` - `NIN("nin")` - `Value value` - `double` - `List` - `Optional fullTextPipelineWeight` Weight of the full-text search pipeline (0-1). - `Optional numCandidates` Number of candidates for approximate nearest neighbor search. - `Optional rerank` Reranking configuration applied after hybrid search. Enabled by default. - `Optional enabled` Set to false to disable reranking. - `Optional topN` Number of results to return after reranking. - `Optional scoreThreshold` Minimum score threshold for returned results. - `Optional staticFilters` Filters on built-in document fields (page range, chunk index, etc.). - `Optional parsedDirectoryFileId` - `Operator operator` - `EQ("eq")` - `NE("ne")` - `GT("gt")` - `LT("lt")` - `GTE("gte")` - `LTE("lte")` - `IN("in")` - `NIN("nin")` - `Value value` - `String` - `List` - `Optional topK` Maximum number of results to return. - `Optional vectorPipelineWeight` Weight of the vector search pipeline (0-1). ### Returns - `class RetrievalRetrieveResponse:` Response containing retrieval results. - `List results` Ordered list of retrieved chunks. - `String content` Text content of the retrieved chunk. - `Optional metadata` User-defined metadata associated with the chunk. - `String` - `long` - `double` - `boolean` - `JsonValue;` - `List` - `Optional rerankScore` Relevance score from the reranker, if reranking was applied. - `Optional score` Hybrid search relevance score. - `Optional staticFields` Built-in fields stored for every exported chunk. - `Optional> 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 chunkEndChar` End character offset of the chunk. - `Optional chunkIndex` Index of the chunk within the file. - `Optional chunkStartChar` Start character offset of the chunk. - `Optional chunkTokenCount` Token count of the chunk. - `Optional pageRangeEnd` Last page number covered by this chunk. - `Optional pageRangeStart` First page number covered by this chunk. - `Optional parsedDirectoryFileId` ID of the parsed file. ### Example ```java 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); } } ``` #### Response ```json { "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" } } ] } ``` ## Find Files `RetrievalFindPage beta().retrieval().find(RetrievalFindParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` **post** `/api/v1/retrieval/files/find` Search for files by name. ### Parameters - `RetrievalFindParams params` - `Optional organizationId` - `Optional projectId` - `String indexId` ID of the index to search within. - `Optional fileName` Exact file name to match. - `Optional fileNameContains` Substring match on file name (case-insensitive). - `Optional pageSize` The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum. - `Optional pageToken` A page token, received from a previous list call. Provide this to retrieve the subsequent page. ### Returns - `class RetrievalFindResponse:` A file returned by find. - `String fileId` ID of the file. - `String fileName` Display name of the file. ### Example ```java 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.RetrievalFindPage; import com.llamacloud_prod.api.models.beta.retrieval.RetrievalFindParams; public final class Main { private Main() {} public static void main(String[] args) { LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv(); RetrievalFindParams params = RetrievalFindParams.builder() .indexId("idx-abc123") .build(); RetrievalFindPage page = client.beta().retrieval().find(params); } } ``` #### Response ```json { "items": [ { "file_id": "file_id", "file_name": "file_name" } ], "next_page_token": "next_page_token", "total_size": 0 } ``` ## Grep File `RetrievalGrepPage beta().retrieval().grep(RetrievalGrepParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` **post** `/api/v1/retrieval/files/grep` Grep within a file's parsed content using a regex pattern. ### Parameters - `RetrievalGrepParams params` - `Optional organizationId` - `Optional projectId` - `String fileId` ID of the file to grep. - `String indexId` ID of the index the file belongs to. - `String pattern` Regex pattern to search for. - `Optional contextChars` Number of characters of context to include before and after the matched pattern in the content field of the response - `Optional pageSize` The maximum number of items to return. The service may return fewer than this value. If unspecified, a default page size will be used. The maximum value is typically 1000; values above this will be coerced to the maximum. - `Optional pageToken` A page token, received from a previous list call. Provide this to retrieve the subsequent page. ### Returns - `class RetrievalGrepResponse:` A single grep match within a file. - `String content` Matched text content. - `long endChar` End character offset of the match. - `long startChar` Start character offset of the match. ### Example ```java 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.RetrievalGrepPage; import com.llamacloud_prod.api.models.beta.retrieval.RetrievalGrepParams; public final class Main { private Main() {} public static void main(String[] args) { LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv(); RetrievalGrepParams params = RetrievalGrepParams.builder() .fileId("file_id") .indexId("idx-abc123") .pattern("revenue|profit") .build(); RetrievalGrepPage page = client.beta().retrieval().grep(params); } } ``` #### Response ```json { "items": [ { "content": "content", "end_char": 0, "start_char": 0 } ], "next_page_token": "next_page_token", "total_size": 0 } ``` ## Read File `RetrievalReadResponse beta().retrieval().read(RetrievalReadParamsparams, RequestOptionsrequestOptions = RequestOptions.none())` **post** `/api/v1/retrieval/files/read` Read the parsed text content of a specific file. ### Parameters - `RetrievalReadParams params` - `Optional organizationId` - `Optional projectId` - `String fileId` ID of the file to read. - `String indexId` ID of the index the file belongs to. - `Optional maxLength` Maximum number of characters to read from the offset. - `Optional offset` Starting character offset. ### Returns - `class RetrievalReadResponse:` File read result. - `String content` Parsed text content of the file. ### Example ```java 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.RetrievalReadParams; import com.llamacloud_prod.api.models.beta.retrieval.RetrievalReadResponse; public final class Main { private Main() {} public static void main(String[] args) { LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv(); RetrievalReadParams params = RetrievalReadParams.builder() .fileId("file_id") .indexId("idx-abc123") .build(); RetrievalReadResponse response = client.beta().retrieval().read(params); } } ``` #### Response ```json { "content": "content" } ```