Order web search results Stay organized with collections Save and categorize content based on your preferences.
Ordering is a type of ranking mechanism that dynamically changes the sequence inwhich results are returned after an initial ranking that's established duringthe retrieval process. During retrieval, Vertex AI Search fetches the relevantdocuments from the data store in the order of thousands (subject to the size ofthe data store). After this the top results are served according to thecondition specified for reordering. For more information, seeAbout retrieval and ranking.
This page explains how to order the results of a web search query by date.
- For data stores that use basic website search, you can order byGoogle-inferred page dates.
- For data stores that use advanced website indexing, you can order bycustom data attributes or Google-inferred page dates that are added to thedata store schema. For more information, seeUse structured data for advanced website indexing.
Before you begin
Make sure that you do the following:
Create a data store with website data. For more information, seeWebsiteURLs.
Create a search app and connect it to the data store. For more information,seeCreate a search app.
Order search results for basic website search
To order the search results for a website data store withbasic website search, follow these steps:
REST
The following sample shows how to to order your web search results for an appwith basic website search. This sample uses theengines.servingConfigs.search method:
engines.servingConfigs.search method and you can search over a data store using thedataStores.servingConfigs.search method. For the following procedure, Google recommends searching using theengines.servingConfigs.search method.Find your app ID. If you already have your app ID, skip to the next step.
In the Google Cloud console, go to theAI Applications page.
On theApps page, find the name of your app and get the app's ID fromtheID column.
Make a search query and include the
Key Term: In Vertex AI Search, the termapp can be used interchangeably with the termengine in the context of APIs.orderByfield.curl-XPOST-H"Authorization: Bearer$(gcloudauthprint-access-token)"\-H"Content-Type: application/json"\"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search:search"\-d'{"servingConfig": "projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search","query": "QUERY","orderBy": "ORDER_BY"}'Replace the following:
PROJECT_ID: the ID of your Google Cloud project.APP_ID: the ID of the Vertex AI Search app.QUERY: the query text to search.ORDER_BY: the order in which the results are arranged. For example, to order chronologically, specifydateto return web pages sorted by Google-inferred page date. For more information on the Google-inferred page date, see theHelp Google Search know the best date for your web page blog post. The default sort order is descending, in which the pages with the most recent dates are returned first. To get ascending sort order, append:ato thedatevalue—date:a.
Order search results for advanced website indexing
To order the search results for a website data store withadvanced website indexing, follow these steps:
REST
The following sample shows how to order your web search results for an appwith advanced website indexing. This sample uses theengines.servingConfigs.search method:
engines.servingConfigs.search method and you can search over a data store using thedataStores.servingConfigs.search method. For the following procedure, Google recommends searching using theengines.servingConfigs.search method.Find your app ID. If you already have your app ID, skip to the next step.
In the Google Cloud console, go to theAI Applications page.
On theApps page, find the name of your app and get the app's ID fromtheID column.
Make a search query and include the
Key Term: In Vertex AI Search, the termapp can be used interchangeably with the termengine in the context of APIs.orderByfield.curl-XPOST-H"Authorization: Bearer$(gcloudauthprint-access-token)"\-H"Content-Type: application/json"\"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search:search"\-d'{"servingConfig": "projects/PROJECT_ID/locations/global/collections/default_collection/engines/APP_ID/servingConfigs/default_search","query": "QUERY","orderBy": "ORDER_BY"}'Replace the following:
PROJECT_ID: the ID of your Google Cloud project.APP_ID: the ID of the Vertex AI Search app.QUERY: the query text to search.ORDER_BY: the order in which the results are arranged. The field can have values that are of the following data types: datetime, integer, or number. To order chronologically, specify the custom date attribute specified in the schema or the Google-inferred page date to return web pages sorted by date. For example, to order by adate_editedPageMap attribute, you can specify theorderByfield as"orderBy": "date_edited". The default sort order is ascending, in which older pages are returned first. To get the results in descending order, appenddescto the custom attribute value—for example,"orderBy":"date_edited desc".
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.