liveBook · Manning

_search API

As explained in Elasticsearch in Action, Second Edition

The Elasticsearch HTTP endpoint for submitting search requests and retrieving matching documents or aggregation results.

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

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains URI requests, Query DSL, index selection, scoring, and aggregations, while deferring detailed query types to later treatment.
Examples
Demonstrates movie-title searches for Godfather, multiword URI queries, match requests, scoring explanations, and COVID-data aggregations.
What it assumes
Assumes indexed documents and basic HTTP requests, while introducing search requests, Query DSL structure, and index targeting.
What you can do after
Operate/configure searches through URI parameters or JSON Query DSL, including multi-index requests and combined search-aggregation queries.
How it connects
Connects search queries with Query DSL, full-text search, structured search, relevance scoring, pagination, highlighting, and aggregations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.