Order web search results

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:

Note: You can search over an app using theengines.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.
  1. Find your app ID. If you already have your app ID, skip to the next step.

    1. In the Google Cloud console, go to theAI Applications page.

      Go to Apps

    2. On theApps page, find the name of your app and get the app's ID fromtheID column.

  2. Make a search query and include theorderBy field.

    Key Term: In Vertex AI Search, the termapp can be used interchangeably with the termengine in the context of APIs.
    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:

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:

Note: You can search over an app using theengines.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.
  1. Find your app ID. If you already have your app ID, skip to the next step.

    1. In the Google Cloud console, go to theAI Applications page.

      Go to Apps

    2. On theApps page, find the name of your app and get the app's ID fromtheID column.

  2. Make a search query and include theorderBy field.

    Key Term: In Vertex AI Search, the termapp can be used interchangeably with the termengine in the context of APIs.
    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_edited PageMap attribute, you can specify theorderBy field as"orderBy": "date_edited". The default sort order is ascending, in which older pages are returned first. To get the results in descending order, appenddesc to 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.