Searches the Documents of a single DataStore.
Returns ranked sub-document segments, each referring back to the Document it came from and carrying the provenance needed to cite it.
HTTP request
POST https://vectorsearch.googleapis.com/v1beta/{parent}/documents:search
Path parameters
| Parameters | |
|---|---|
parent |
Required. The DataStore to search. Format: |
Request body
The request body contains data with the following structure:
| JSON representation |
|---|
{ "topK": integer, "documentIds": [ string ], "rankingSpec": { object ( |
| Fields | |
|---|---|
topK |
Optional. Number of results to return. Defaults to 10. Values above 100 are coerced to 100. |
documentIds[] |
Optional. Restrict the search to these Document IDs. Max 100. If empty, the whole DataStore is searched. |
rankingSpec |
Optional. Controls how results are ranked. |
filter |
Optional. Restricts the search to segments that match this filter, a JSON object over the field paths of a
Comparisons: {"$and": [{"metadata.year": {"$gte": 2025}}, {"unstructured_details.page_range.start_page": {"$lte": 20}}]} |
outputFields |
Optional. Fields to return on each result. |
| Required. The query to search for. Exactly one query type must be set. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: | |
textQuery |
A text query. |
| End of mutually exclusive fields. | |
Response body
Response message for DocumentSearchService.SearchDocuments.
If successful, the response body contains data with the following structure:
| JSON representation |
|---|
{ "results": [ { object ( |
| Fields | |
|---|---|
results[] |
Output only. The matching document segments that match the search criteria, ordered by relevance. |
warnings[] |
Output only. Warnings or non-fatal errors that occurred during execution. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-platformhttps://www.googleapis.com/auth/vectorsearchhttps://www.googleapis.com/auth/vectorsearch.readonly
For more information, see the Authentication Overview.
TextQuery
A text query.
| JSON representation |
|---|
{ "text": string } |
| Fields | |
|---|---|
text |
Required. The text to search for. |
RankingSpec
Controls how results are ranked.
| JSON representation |
|---|
{
"rerankingSpec": {
object ( |
| Fields | |
|---|---|
rerankingSpec |
Optional. Controls the re-ranking stage. |
RerankingSpec
Configuration for semantic re-ranking applied to candidate results after hybrid retrieval and Reciprocal Rank Fusion (RRF).
| JSON representation |
|---|
{ "enabled": boolean, "rankOversamplingFactor": integer } |
| Fields | |
|---|---|
enabled |
Optional. Whether to re-rank the fused results. Defaults to false: results are returned in RRF-fused order unless the caller opts in. When enabled, re-ranking uses Not supported for a |
rankOversamplingFactor |
Optional. The factor by which to oversample candidates before re-ranking. The total number of candidates retrieved for re-ranking is Ignored unless To re-rank without oversampling, set this field to 1. |
OutputFields
Fields to return on each DocumentSearchResult, beyond those every result carries.
| JSON representation |
|---|
{ "metadata": [ string ] } |
| Fields | |
|---|---|
metadata[] |
Optional. Metadata properties to return in |
DocumentSearchResult
A single matching segment of a Document.
| JSON representation |
|---|
{ "document": { object ( |
| Fields | |
|---|---|
document |
Output only. The Document this segment came from, including its resource name and the Cloud Storage location it was ingested from. Note that not all Document fields are populated. For the full Document, call documents.get on the returned document name. |
Details of where the segment sits within its Document. Which field is set follows the parent DataStore's document_type. The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: |
|
videoDetails |
Set when the parent DataStore's |
unstructuredDetails |
Set when the parent DataStore's |
| End of mutually exclusive fields. | |
VideoSegmentDetails
Locates a segment within a video Document.
| JSON representation |
|---|
{ "startOffset": string, "endOffset": string } |
| Fields | |
|---|---|
startOffset |
Output only. Where this segment begins, relative to the start of the source video. A duration in seconds with up to nine fractional digits, ending with ' |
endOffset |
Output only. Where this segment ends, relative to the start of the source video. A duration in seconds with up to nine fractional digits, ending with ' |
UnstructuredSegmentDetails
Locates a segment within an unstructured Document, and carries its text.
| JSON representation |
|---|
{
"contentSnippet": string,
"pageRange": {
object ( |
| Fields | |
|---|---|
contentSnippet |
Output only. Text content of the segment. |
pageRange |
Output only. Where the segment sits in the source document. Set for PDF, PowerPoint and Excel files, where a page is a PDF page, a slide or a sheet. For plain-text and Word files, set only when the file is split into pages ( |
PageRange
A page range within the source document. Pages are 1-based and the range is inclusive; a single page is represented as startPage == endPage.
| JSON representation |
|---|
{ "startPage": string, "endPage": string } |
| Fields | |
|---|---|
startPage |
Output only. First page of the range. |
endPage |
Output only. Last page of the range. |