- 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
Elasticsearch search API for App Search
editElasticsearch search API for App Search
editA valid App Search authentication header is required to access this endpoint, and the authenticated entity must have read
access to the underlying index.
Submit an Elasticsearch search request to the document indices that power an App Search engine and retrieve the results.
You can use this API with regular engines and meta engines.
GET <enterprise-search-base-url>/api/as/v1/engines/<engine>/elasticsearch/_search
POST <enterprise-search-base-url>/api/as/v1/engines/<engine>/elasticsearch/_search
Path parameters
edit-
enterprise-search-base-url
(required) - The Enterprise Search base URL for the deployment.
-
engine
(required) - The engine name.
Request body
editThe body of the request contains the Elasticsearch query. The query can be written using the Elasticsearch Query DSL.
Query string parameters
editAny parameters (key=value
) included in the query string will be passed unmodified to Elasticsearch.
Analytics parameters
editAnalytics parameters can be specified using optional request headers.
-
X-Enterprise-Search-Analytics
-
Specify the search query associated with this request when recording search analytics.
-
X-Enterprise-Search-Analytics-Tags
Query analytics are recorded only if the X-Enterprise-Search-Analytics
header is specified.
Response body
editResponse is returned directly from Elasticsearch and depends on the provided request and its parameters. Unlike the Search endpoint, this endpoint does not do any parsing or formatting of the Elasticsearch response, it simply passes the response back as-is.
Examples
editRetrieve all documents for a given engine:
curl --request "POST" \ --url "${ENTERPRISE_SEARCH_BASE_URL}/api/as/v1/engines/national-parks-demo/elasticsearch/_search" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer private-xxxxxx" \ --data '{"query": {"match_all": {}}}'
Response (10 documents are returned, but only 1 is shown here):
{ "took": 2, "timed_out": false, "_shards": { "total": 2, "successful": 2, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 59, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": ".ent-search-engine-documents-national-parks-demo", "_id": "park_acadia", "_score": 1.0, "_ignored": [ "description.date", "title.float", "date_established.location", "acres.location", "nps_link.date", "world_heritage_site.float", "acres.date", "states.float", "title.location", "states.location", "visitors.date", "location.float", "world_heritage_site.date", "description.float", "description.location", "nps_link.float", "square_km.location", "title.date", "location.date", "nps_link.location", "world_heritage_site.location", "states.date", "square_km.date", "date_established.float" ], "_source": { "description": "Covering most of Mount Desert Island and other coastal islands, Acadia features the tallest mountain on the Atlantic coast of the United States, granite peaks, ocean shoreline, woodlands, and lakes. There are freshwater, estuary, forest, and intertidal habitats.", "nps_link": "https://www.nps.gov/acad/index.htm", "states": [ "Maine" ], "title": "Acadia", "visitors": "3303393", "world_heritage_site": "false", "location": "44.35,-68.21", "acres": "49057.36", "square_km": "198.5", "date_established": "1919-02-26T06:00:00Z", "id": "park_acadia" } } ] } }
By default, Elasticsearch returns 10 documents, unless the size
parameter is specified. Example request with size
:
curl --request "POST" \ --url "${ENTERPRISE_SEARCH_BASE_URL}/api/as/v1/engines/national-parks-demo/elasticsearch/_search?size=1" \ --header "Content-Type: application/json" \ --header "Authorization: Bearer private-xxxxxx" \ --data '{"query": {"match_all": {}}}'
Response:
{ "took": 0, "timed_out": false, "_shards": { "total": 2, "successful": 2, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 59, "relation": "eq" }, "max_score": 1.0, "hits": [ { "_index": ".ent-search-engine-documents-national-parks-demo", "_id": "park_acadia", "_score": 1.0, "_ignored": [ "description.date", "title.float", "date_established.location", "acres.location", "nps_link.date", "world_heritage_site.float", "acres.date", "states.float", "title.location", "states.location", "visitors.date", "location.float", "world_heritage_site.date", "description.float", "description.location", "nps_link.float", "square_km.location", "title.date", "location.date", "nps_link.location", "world_heritage_site.location", "states.date", "square_km.date", "date_established.float" ], "_source": { "description": "Covering most of Mount Desert Island and other coastal islands, Acadia features the tallest mountain on the Atlantic coast of the United States, granite peaks, ocean shoreline, woodlands, and lakes. There are freshwater, estuary, forest, and intertidal habitats.", "nps_link": "https://www.nps.gov/acad/index.htm", "states": [ "Maine" ], "title": "Acadia", "visitors": "3303393", "world_heritage_site": "false", "location": "44.35,-68.21", "acres": "49057.36", "square_km": "198.5", "date_established": "1919-02-26T06:00:00Z", "id": "park_acadia" } } ] } }
For more guidance and examples, please see the Elasticsearch search guide.
Limitations
editThis API only exposes the Elasticsearch Search API. It’s currently not possible to access other Elasticsearch search APIs, such as Multi search API, Scroll API, Async search API, etc.
See also
editYou can see exactly how App Search searches for the documents if you use the related Search Explain API endpoint. That endpoint will build and return an Elasticsearch search query being used by App Search. The query can be used as a starting point to create your own queries.
More examples are available in the Elasticsearch search guide.
On this page