Method: documents.searchDocumentChunks

Searches for developer knowledge across Google's developer documentation. Returns DocumentChunks based on the user's query. There may be many chunks from the same Document. To retrieve full documents, use DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments with the DocumentChunk.parent returned in the SearchDocumentChunksResponse.results.

HTTP request

GET https://developerknowledge.googleapis.com/v1/documents:searchDocumentChunks

The URL uses gRPC Transcoding syntax.

Query parameters

Parameters
query

string

Required. Provides the raw query string provided by the user, such as "How to create a Cloud Storage bucket?".

pageSize

integer

Optional. Specifies the maximum number of results to return. The service may return fewer than this value.

If unspecified, at most 5 results will be returned.

The maximum value is 20; values above 20 will result in an INVALID_ARGUMENT error.

pageToken

string

Optional. Contains a page token, received from a previous documents.searchDocumentChunks call. Provide this to retrieve the subsequent page.

filter

string

Optional. Applies a strict filter to the search results. The expression supports a subset of the syntax described at https://google.aip.dev/160.

While documents.searchDocumentChunks returns DocumentChunks, the filter is applied to DocumentChunk.document fields.

Supported fields for filtering:

  • dataSource (STRING): The source of the document, e.g. docs.cloud.google.com. See https://developers.google.com/knowledge/reference/corpus-reference for the complete list of data sources in the corpus.
  • updateTime (TIMESTAMP): The timestamp of when the document was last meaningfully updated. A meaningful update is one that changes document's markdown content or metadata.
  • uri (STRING): The document URI, e.g. https://docs.cloud.google.com/bigquery/docs/tables.

STRING fields support = (equals) and != (not equals) operators for exact match on the whole string. Partial match, prefix match, and regexp match are not supported.

TIMESTAMP fields support =, <, <=, >, and >= operators. Timestamps must be in RFC-3339 format, e.g., "2025-01-01T00:00:00Z".

You can combine expressions using AND, OR, and NOT (or -) logical operators. OR has higher precedence than AND. Use parentheses for explicit precedence grouping.

Examples:

  • dataSource = "docs.cloud.google.com" OR dataSource = "firebase.google.com"
  • dataSource != "firebase.google.com"
  • updateTime < "2024-01-01T00:00:00Z"
  • updateTime >= "2025-01-22T00:00:00Z" AND (dataSource = "developer.chrome.com" OR dataSource = "web.dev")
  • uri = "https://docs.cloud.google.com/release-notes"

The filter string must not exceed 500 characters; values longer than 500 characters will result in an INVALID_ARGUMENT error.

Request body

The request body must be empty.

Response body

Response message for DeveloperKnowledge.SearchDocumentChunks.

If successful, the response body contains data with the following structure:

JSON representation
{
  "results": [
    {
      object (DocumentChunk)
    }
  ],
  "nextPageToken": string
}
Fields
results[]

object (DocumentChunk)

Contains the search results for the given query. Each DocumentChunk in this list contains a snippet of content relevant to the search query. Use the DocumentChunk.parent field of each result with DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments to retrieve the full document content.

nextPageToken

string

Optional. Provides a token that can be sent as pageToken to retrieve the next page. If this field is omitted, there are no subsequent pages.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/devprofiles.full_control
  • https://www.googleapis.com/auth/cloud-platform

For more information, see the OAuth 2.0 Overview.

DocumentChunk

A DocumentChunk represents a piece of content from a Document in the DeveloperKnowledge corpus. To fetch the entire document content, pass the parent to DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments.

JSON representation
{
  "parent": string,
  "id": string,
  "content": string,
  "document": {
    object (Document)
  }
}
Fields
parent

string

Output only. Contains the resource name of the document this chunk is from. Format: documents/{uri_without_scheme} Example: documents/docs.cloud.google.com/storage/docs/creating-buckets

id

string

Output only. Specifies the ID of this chunk within the document. The chunk ID is unique within a document, but not globally unique across documents. The chunk ID is not stable and may change over time.

content

string

Output only. Contains the content of the document chunk.

document

object (Document)

Output only. Represents metadata about the Document this chunk is from. The DocumentView of this Document message will be set to DOCUMENT_VIEW_BASIC. It is included here for convenience so that clients do not need to call DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments if they only need the metadata fields. Otherwise, clients should use DeveloperKnowledge.GetDocument or DeveloperKnowledge.BatchGetDocuments to fetch the full document content.