curl -X POST -H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1alpha/projects/my-project-123/locations/global/collections/default_collection/engines/my-app/servingConfigs/default_search:search" \
-d '{
"query": "hotel",
"orderBy": "rating desc"
}'
{
"results": [
{
"id": "10d480b19c256bb1",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/10d480b19c256bb1",
"id": "10d480b19c256bb1",
"structData": {
"available_date": "2023-11-05",
"amenities": [
"Lake Views",
"Private Beach",
"Spa",
"Water Activities"
],
"room_types": [
"Lakefront Suite",
"Deluxe Room",
"Cottage"
],
"location": {
"address": "988 Serenity Circle, Tranquil Town, NV 89501, USA"
},
"rating": 4.6,
"id": 11,
"price_per_night": 220.5,
"title": "Serenity Springs Hotel"
}
}
},
{
"id": "9ffae8af37cc8b63",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/9ffae8af37cc8b63",
"id": "9ffae8af37cc8b63",
"structData": {
"title": "Riverfront Plaza Hotel",
"rating": 4.2,
"location": {
"address": "101 Main St, Anytown, CA 94501, USA"
},
"price_per_night": 145.8,
"amenities": [
"Fitness Center",
"Conference Rooms",
"Restaurant",
"Valet Parking"
],
"id": 3,
"room_types": [
"Executive Suite",
"King Room",
"Double Queen"
],
"available_date": "2023-11-15"
}
}
},
{
"id": "3be9e854d8f3a47f",
"document": {
"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/branches/0/documents/3be9e854d8f3a47f",
"id": "3be9e854d8f3a47f",
"structData": {
"amenities": [
"Oceanfront Views",
"Pool",
"Spa",
"Beachside Dining"
],
"available_date": "2023-09-18",
"location": {
"address": "449 Oceanfront Drive, Seaside Resort, CA 92007, USA"
},
"id": 13,
"title": "Ocean Breeze Hotel",
"room_types": [
"Ocean View Suite",
"Deluxe Room",
"Family Suite"
],
"rating": 4.1,
"price_per_night": 180
}
}
}
],
"totalSize": 3,
"attributionToken": "wAHwvwoMCNDYz7UGEMCklrsCEiQ2NmIzYmU5My0wMDAwLTIxMDUtYmUyNy01ODI0MjljMzdlZTQiB0dFTkVSSUMqgAHd1akt3e2ILebtiC2CspoigLKaIpjeqC-q-LMtjr6dFeqCsS2W3qgvwvCeFaz4sy2jgJcinta3LeiCsS3b7Ygt5O2ILa3Eii3Usp0Vpp-VLZzWty359rMt-_azLaCJsy3dj5oixcvzF6vEii2iibMttreMLd_VqS3bj5oipJ-VLQ",
"guidedSearchResult": {},
"summary": {}
}
In this example, the documents that contain the word "hotel" are ordered by
rating, from the Serenity Springs Hotel with a 4.6 rating to the Ocean Breeze
Hotel with a 4.1 rating.