The _search endpoint is Elasticsearch’s HTTP interface for submitting search requests and retrieving matching documents, relevance scores, or aggregation results. Call it with GET or POST against an index, an index pattern, or the entire cluster. section 8.4 section 8.9
Choose an invocation style according to the complexity of the search:
- Use a URI request for a compact query such as GET movies/_search?q=title:Godfather. section 8.4.1 section 8.6.1
- Use Query DSL for JSON request bodies, compound criteria, advanced queries, pagination, highlighting, scoring explanations, and result manipulation. section 8.4.1 section 8.9
- Search several indexes by listing comma-separated names or wildcards; omit the index to search across all indexes. section 10.5.1
- Replace query with aggs when requesting aggregations, or combine aggs and query to search and analyze the same result set. section 2.6
Search movie titles with Query DSL
GET movies/_search { "query": { "match": { "title": "Godfather" } } } The match query searches the title field for Godfather. A response returns matching movie documents; relevance scoring ranks how well they match. Add explain=true when diagnosing how scores were derived. section 8.4.1 section 8.6.1
GET movies/_search
{
"query": {
"match": {
"title": "Godfather"
}
}
}
Use this runnable request to see the preferred JSON-based form of a movie search. section 8.4.1
