Stay organized with collectionsSave and categorize content based on your preferences.
This page shows how to preview search results using the Google Cloud console and get
search results using the API.
Also, instead of using the web app UI, you can make API calls and integrate
those calls into your server or application. This page includes code samples for
how to make search queries using the gRPC client libraries with a service
account.
Get search results
You can preview search results from the Google Cloud console or get search results
using the API.
Console
To use the Google Cloud console to preview search results for an app with structured
or unstructured data, follow these steps:
Open thePreviewpage in the console.
Type a search query.
If you enabled autocomplete in step 1, you'll see a list of
autocomplete suggestions below the search bar as you type.
(Optional) If you connected multiple data stores to your app but want
results only from a specific data store, select the data store to get
results from.
ClickEnterto submit the query.
A list of search results appears below the search bar.
If no attribute mapping is defined in theConfigurationspage, each search result appears as a list of raw attribute names and values.
If any attribute mappings were saved in theConfigurationspage, the search results display the same images that you see in theConfigurationspage preview.
If any facets were specified in theConfigurationspage, they are
displayed in the same way.
Click the arrow below the results list to load the next page of results.
REST
To use the API to get search results for an app with structured or unstructured
data, use theengines.servingConfigs.searchmethod:
Find your app ID. If you already have your app ID, skip to the next step.
In the Google Cloud console, go to theAgentspacepage.
USER_PSEUDO_ID: optional. This is a pseudonymized identifier
for tracking a search visitor. Google strongly recommends using this
field, which improves model performance and personalization
quality. You can use an HTTP cookie for this field, which uniquely
identifies a visitor on a single device. This identifier does not change
when the visitor signs in or out of a website. Don't set this field to
the same identifier for multiple users—this would combine their event
histories and degrade model quality. Don't include personally
identifiable information (PII) in this field.
PAGE_SIZE: the number of results returned by
the search. The maximum allowed page size depends on the data type. Page
sizes above the maximum value are coerced to the maximum value.
Websites with basic indexing: Default10, Maximum25
Websites with advanced indexing: Default25, Maximum50
Other: Default50, Maximum100
OFFSET: optional. The starting index of the results.
The default value is 0.
For example, if the offset is 2, the page size is 10,
and there are 15 results to return, results 2 through 11 are
returned on the first page.
ORDER_BY: optional. The order in which the results are
arranged.
FILTER: optional. A text field for filtering your search
using a filter expression. The default value is an empty string, which
means no filter is applied.
Example:color: ANY("red", "blue") AND score: IN(*, 100.0e)
BOOST_SPEC: optional. A specification to
boost or bury documents. Values:
BOOST:
a floating point number in the range [-1,1]. When the value is
negative, results are demoted (they appear lower down in the
results). When the value is positive, results are promoted
(they appear higher up in the results).
CONDITION:
atext filter expressionto select the documents to which boost is applied. The filter must evaluate
to a boolean value.
FACET_SPEC: optional. A facet specification to perform
faceted search.
QUERY_EXPANSION_SPEC: optional. A specification to
determine under which conditions query expansion should occur. Default
isDISABLED.
SPELL_CORRECTION_SPEC: optional. A specification to
determine under which conditions spell correction should occur. Default
isAUTO.
CONTENT_SEARCH_SPEC: optional. For getting snippets,
extractive answers, extractive segments, and search summaries. For
unstructured data only. For more information, see:
DATA_STORE_SPEC: filters for a specific data store to search across. This can be used if your search app is connected
to multiple data stores. For more information, seeDataStoreSpec.
Viewing guided search results in the search response:
Guided search results are returned with search responses for structured
and unstructured search. The guided search result contains a list of
extracted attribute key-value pairs based on search result documents. This
allows users to refine their search results by using some attribute keys
and values as filters.
In this example response, the color green was used to refine search
results by issuing a new search request with the filter field specified as_gs.color: ANY("green"):
Document-relevance scores are based on the similarity of the query to the
document. Scores are put into 11 buckets in the range: 0, 0.1, 0.2, … to 1.0.
The higher the score, the more relevant the document.
Consider document-relevance scores for these use cases:
Post-search filtering based on the relevance score to remove
irrelevant results
Post-search ranking or as input to other applications
Debugging: relevance scores can provide insight into why some search
results are returned
For each search result, a relevance score can be returned:
Also see the example command in the procedure below.
Before you begin:Make sure that the search app is associated with a
structured or unstructured data store. That is, document-relevance scores can't
be returned for website search app.
REST
To request that document-relevance scores be returned with search results, use
theengines.servingConfigs.searchmethod as
follows:
Find your app ID. If you already have your app ID, skip to the next step.
In the Google Cloud console, go to theAgentspacepage.
curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:search" \
-d '{
"servingConfig": "projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search",
"query": "When was Verily founded and what is its mission?","relevanceScoreSpec": {
"returnRelevanceScore": true}
}'{
"results": [
{
"id": "f1b0d98bd2a078a6dfb4f809c3028565",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/f1b0d98bd2a078a6dfb4f809c3028565",
"id": "f1b0d98bd2a078a6dfb4f809c3028565",
"derivedStructData": {
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2019_alphabet_annual_report.pdf",
"extractive_answers": [
{
"pageNumber": "70",
"content": "VERILY Verily is a life science and healthcare company with a mission to make the world's health data useful so that people enjoy healthier lives. In December 2018, Verily received $900 million in cash from a $1.0 billion investment round. The remaining $100 million was received in the first quarter of 2019."
}
],
"title": "2019_alphabet_annual_report"
}
},"modelScores": {
"relevance_score": {
"values": [
0.7
]
}
}},
{
"id": "0371b29bfa18ac43896b86a7b63d00b0",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/0371b29bfa18ac43896b86a7b63d00b0",
"id": "0371b29bfa18ac43896b86a7b63d00b0",
"derivedStructData": {
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/20190429_alphabet_10Q.pdf",
"title": "GOOG 10-Q Q1 2019",
"extractive_answers": [
{
"content": "Verily Verily is a life science company with a mission to make the world's health data useful so that people enjoy healthier lives. In December 2018, Verily received $900 million in cash from a $1.0 billion investment round. The remaining $100 million was received in the first quarter of 2019.",
"pageNumber": "21"
}
]
}
},"modelScores": {
"relevance_score": {
"values": [
0.5
]
}
}},
...
{
"id": "e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"id": "e6bbd0d82dc2a2fc7ccf1bd82ac6334f",
"derivedStructData": {
"title": "2021_Q1_Earnings_Transcript",
"link": "gs://cloud-samples-data/gen-app-builder/search/alphabet-investor-pdfs/2021_Q1_Earnings_Transcript.pdf",
"extractive_answers": [
{
"pageNumber": "2",
"content": "Our strength in AI and ML is also helping Financial Services customers improve efficiency of payments, reduce fraud and risk, and deliver faster payment solutions."
}
]
}
},"modelScores": {
"relevance_score": {
"values": [
0
]
}
}}
],
"totalSize": 76,
"attributionToken": "8QHw8AoLCIW4_b0GELHd3lgSJDY3YmU1ZGMwLTAwMDAtMmM1OC04NzcyLTc0NzQ0NjNiOGMyNSIHR0VORVJJQyqcAcb77TDHy_MX8tntMI6-nRWK4uQwwvCeFYX77TDvifIwq8SKLauR3zCq-LMt0IrIMNSynRWc1rctv_7kML7l3zDZveQwkPeyMMP77TD12e0wpd_hMIfi5DCRv9owgvvtMJWSxTCOkckwu-XfMK7Eii3sifIwqJHfMKjf4TCt-LMtlL_aMJ_Wty23t4wto4CXIs2KyDDcveQwwv7kMDABShIweDU3MGFkYWI4MzQ4NmY0MGE",
"nextPageToken": "UjMjhjYzYDN0cDN30iM3cDOtgTNjJTLwADMw0iZiRWNlJ2N2QiGBUd0gWLEG4bjhWICMIBM1IgC",
"summary": {},
"queryExpansionInfo": {}
}
Search summarization differs by model
If you generate search summaries for your queries, you might notice that
the summaries differ between the console results and the API results. If you
see this, the likely reason is that the console is using a different LLM model
from the API. The curl and code examples on this page use the stable LLM model.
To change or view the LLM model used in thePreviewpage of the UI, go to
theConfigurationspage >UItab for your app.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-05 UTC."],[],[],null,[]]