- App Search Guide: other versions:
- Installation
- Getting started
- Authentication
- Limits
- Users and access
- Guides
- Adaptive relevance events logs reference
- Analytics Tags
- Crawl web content
- Crawl a private network using a web crawler on Elastic Cloud
- Crawl custom fields using proxy
- Curations
- Elasticsearch search
- Elasticsearch index engines
- Create Elasticsearch index engines
- Configure dynamic field mappings and analyzers in an Elasticsearch index engine
- Elasticsearch engines text field conventions
- Facets
- Hierarchical Facets
- Indexing Documents
- Language Optimization
- Log settings
- Meta Engines
- Precision tuning (beta)
- Query Suggestions
- Search UI
- Relevance Tuning
- Result Settings
- Result Suggestions
- Role based access control (RBAC)
- Sanitization, Raw or Snippet
- Search
- Synonyms
- View web crawler events logs
- App Search web crawler
- Web crawler FAQ
- Web crawler reference
- Web crawler events logs reference
- API Reference
- Adaptive relevance API reference (beta)
- Analytics APIs
- Analytics clicks API
- Analytics counts API
- Analytics queries API
- API logs API
- Click API
- Credentials API
- Curations API reference
- Documents API
- Elasticsearch search API
- Engines API
- Log settings API
- Multi search API
- Query suggestion API
- Schema API
- Search API
- Search API boosts
- Search API facets
- Search API filters
- Search API group
- Search API precision (beta)
- Search API result fields
- Search API search fields
- Search API sort
- Search API analytics tags
- Search settings API
- Search Explain API
- Source engines API
- Synonyms API
- Web crawler API reference
- API Clients
- Configuration
- Known issues
- Troubleshooting
ℹ️ For new users, we recommend using our native Elasticsearch tools, rather than the standalone App Search product. We are actively developing new features and capabilities in the Elastic Stack to help you build powerful search applications.
Refer to this blog for more information.
Search API group
editSearch API group
editGrouped results based on shared fields.
The most relevant document will have a _group
key.
The key includes all other documents that share an identical value within the grouped field.
Documents in the _group
key will not appear anywhere else in the search response.
Grouping is available on text, number, and date fields.
-
field
(required) - Field name to group results on.
-
size
(optional) - Number of results to be included in the _group key of the returned document. Can be between 1 and 10. Defaults to 10.
-
sort
(optional) - A JSON object containing the field name or _score as the key and the value as asc or desc. The default sort is by descending relevance.
-
collapse
(optional) - Experimental. Provides Paging and Sorting support. The field you are grouping on must not have multiple values. Multiple values will cause an error.
Example - Searching for "california" and grouping on states
.
curl -X GET '<ENTERPRISE_SEARCH_BASE_URL>/api/as/v1/engines/national-parks-demo/search' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \ -d '{ "query": "parks", "result_fields": { "title": { "raw": {} }, "location": { "raw": {} }, "states": { "raw": {} } }, "group": { "field": "states" } }'
Example Response
{ "meta": { ## Truncated! }, "request_id": "feff7cf2359a6f6da84586969ef0ca89" }, "results": [ { "states": { "raw": [ "California" ] }, "title": { "raw": "Redwood" }, "location": { "raw": "41.3,-124" }, "id": { "raw": "park_redwood" }, "_meta": { "score": 3.6536791 }, "_group": [ { "states": { "raw": [ "California" ] }, "title": { "raw": "Sequoia" }, "location": { "raw": "36.43,-118.68" }, "id": { "raw": "park_sequoia" }, "_meta": { "score": 0.7559763 } }, { "states": { "raw": [ "California" ] }, "title": { "raw": "Lassen Volcanic" }, "location": { "raw": "40.49,-121.51" }, "id": { "raw": "park_lassen-volcanic" }, "_meta": { "score": 0.65168744 } }, { "states": { "raw": [ "California" ] }, "title": { "raw": "Kings Canyon" }, "location": { "raw": "36.8,-118.55" }, "id": { "raw": "park_kings-canyon" }, "_meta": { "score": 0.5489506 } }, { "states": { "raw": [ "California" ] }, "title": { "raw": "Pinnacles" }, "location": { "raw": "36.48,-121.16" }, "id": { "raw": "park_pinnacles" }, "_meta": { "score": 0.49142775 } }, { "states": { "raw": [ "California", "Nevada" ] }, "title": { "raw": "Death Valley" }, "location": { "raw": "36.24,-116.82" }, "id": { "raw": "park_death-valley" }, "_meta": { "score": 0.4451992 } }, { "states": { "raw": [ "California" ] }, "title": { "raw": "Channel Islands" }, "location": { "raw": "34.01,-119.42" }, "id": { "raw": "park_channel-islands" }, "_meta": { "score": 0.12520474 } }, { "states": { "raw": [ "California" ] }, "title": { "raw": "Yosemite" }, "location": { "raw": "37.83,-119.5" }, "id": { "raw": "park_yosemite" }, "_meta": { "score": 0.10190857 } } ], "_group_key": "California" }, ## Truncated! ] }
ElasticON events are back!
Learn about the Elastic Search AI Platform from the experts at our live events.
Register nowWas this helpful?
Thank you for your feedback.