Stay organized with collections
Save and categorize content based on your preferences.
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 by
Google-inferred page dates.
For data stores that use advanced website indexing, you can order by
custom data attributes or Google-inferred page dates that are added to the
data store schema. For more information, see
Use 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, see Website
URLs.
Create a search app and connect it to the data store. For more information,
see Create a search app.
Order search results for basic website search
To order the search results for a website data store with
basic website search, follow these steps:
REST
The following sample shows how to to order your web search results for an app
with basic website search. This sample uses the
engines.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 the AI Applications page.
ORDER_BY: the order in which the results are arranged. For
example, to order chronologically, specify date to return web pages
sorted by Google-inferred page date. For more information on
the Google-inferred page date, see the
Help 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 :a to the date value—date:a.
Order search results for advanced website indexing
To order the search results for a website data store with
advanced website indexing, follow these steps:
REST
The following sample shows how to order your web search results for an app
with advanced website indexing. This sample uses the
engines.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 the AI Applications page.
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 a
date_edited PageMap attribute, you can specify the orderBy 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, append desc to the custom attribute value—for example,
"orderBy":"date_edited desc".
[[["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-08-26 UTC."],[[["\u003cp\u003eThis guide demonstrates how to order web search results by date for both basic and advanced website search configurations.\u003c/p\u003e\n"],["\u003cp\u003eFor basic website search, results can be sorted by Google-inferred page dates using the \u003ccode\u003eorderBy\u003c/code\u003e field set to \u003ccode\u003edate\u003c/code\u003e in the search query.\u003c/p\u003e\n"],["\u003cp\u003eAdvanced website indexing allows sorting by either Google-inferred page dates or custom data attributes defined in the data store schema.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eengines.servingConfigs.search\u003c/code\u003e method is the recommended approach for searching and ordering results for both basic and advanced configurations.\u003c/p\u003e\n"],["\u003cp\u003eWhen sorting, the default is descending order for basic web searches, and ascending order for advanced web searches, but this can be reversed by appending \u003ccode\u003e:a\u003c/code\u003e or \u003ccode\u003edesc\u003c/code\u003e, respectively, to the ordering value.\u003c/p\u003e\n"]]],[],null,["# Order web search results\n\nThis page explains how to order the results of a web search query by date.\n\n- For data stores that use basic website search, you can order by Google-inferred page dates.\n- For data stores that use advanced website indexing, you can order by custom data attributes or Google-inferred page dates that are added to the data store schema. For more information, see [Use structured data for advanced website indexing](/generative-ai-app-builder/docs/add-website-metadata).\n\nBefore you begin\n----------------\n\nMake sure that you do the following:\n\n- Create a data store with website data. For more information, see [Website\n URLs](/generative-ai-app-builder/docs/create-data-store-es#website).\n\n- Create a search app and connect it to the data store. For more information,\n see [Create a search app](/generative-ai-app-builder/docs/create-engine-es).\n\nOrder search results for basic website search\n---------------------------------------------\n\nTo order the search results for a website data store with\nbasic website search, follow these steps: \n\n### REST\n\nThe following sample shows how to to order your web search results for an app\nwith basic website search. This sample uses the\n[`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method:\n| **Note:** You can search over an app using the [`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method and you can search over a data store using the [`dataStores.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/search) method. For the following procedure, Google recommends searching using the `engines.servingConfigs.search` method.\n\n1. Find your app ID. If you already have your app ID, skip to the next step.\n\n 1. In the Google Cloud console, go to the **AI Applications** page.\n\n [Go to Apps](https://console.cloud.google.com/gen-app-builder/engines)\n 2. On the **Apps** page, find the name of your app and get the app's ID from\n the **ID** column.\n\n2. Make a search query and include the `orderBy` field.\n\n **Key Term:** In Vertex AI Search, the term *app* can be used interchangeably with the term *engine* in the context of APIs. \n\n curl -X POST -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://discoveryengine.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search:search\" \\\n -d '{\n \"servingConfig\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search\",\n \"query\": \"\u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e\",\n \"orderBy\": \"\u003cvar translate=\"no\"\u003eORDER_BY\u003c/var\u003e\"\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n - \u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e: the ID of the Vertex AI Search app.\n - \u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e: the query text to search.\n - \u003cvar translate=\"no\"\u003eORDER_BY\u003c/var\u003e: the order in which the results are arranged. For example, to order chronologically, specify `date` to return web pages sorted by Google-inferred page date. For more information on the Google-inferred page date, see the [Help Google Search know the best date for your web page](https://developers.google.com/search/blog/2019/03/help-google-search-know-best-date-for) 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 `:a` to the `date` value---`date:a`.\n\n\u003cbr /\u003e\n\nOrder search results for advanced website indexing\n--------------------------------------------------\n\nTo order the search results for a website data store with\nadvanced website indexing, follow these steps: \n\n### REST\n\nThe following sample shows how to order your web search results for an app\nwith advanced website indexing. This sample uses the\n[`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method:\n| **Note:** You can search over an app using the [`engines.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.engines.servingConfigs/search) method and you can search over a data store using the [`dataStores.servingConfigs.search`](/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores.servingConfigs/search) method. For the following procedure, Google recommends searching using the `engines.servingConfigs.search` method.\n\n1. Find your app ID. If you already have your app ID, skip to the next step.\n\n 1. In the Google Cloud console, go to the **AI Applications** page.\n\n [Go to Apps](https://console.cloud.google.com/gen-app-builder/engines)\n 2. On the **Apps** page, find the name of your app and get the app's ID from\n the **ID** column.\n\n2. Make a search query and include the `orderBy` field.\n\n **Key Term:** In Vertex AI Search, the term *app* can be used interchangeably with the term *engine* in the context of APIs. \n\n curl -X POST -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json\" \\\n \"https://discoveryengine.googleapis.com/v1/projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search:search\" \\\n -d '{\n \"servingConfig\": \"projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/global/collections/default_collection/engines/\u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e/servingConfigs/default_search\",\n \"query\": \"\u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e\",\n \"orderBy\": \"\u003cvar translate=\"no\"\u003eORDER_BY\u003c/var\u003e\"\n }'\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the ID of your Google Cloud project.\n - \u003cvar translate=\"no\"\u003eAPP_ID\u003c/var\u003e: the ID of the Vertex AI Search app.\n - \u003cvar translate=\"no\"\u003eQUERY\u003c/var\u003e: the query text to search.\n - \u003cvar translate=\"no\"\u003eORDER_BY\u003c/var\u003e: 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 a `date_edited` PageMap attribute, you can specify the `orderBy` 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, append `desc` to the custom attribute value---for example, `\"orderBy\":\"date_edited desc\"`.\n\n\u003cbr /\u003e"]]