liveBook · Manning

Match_all query

As explained in Elasticsearch in Action, Second Edition

A match_all query is an Elasticsearch query that matches every document eligible for the search.

Use a match_all query when a bookstore search must return every document in the books index rather than filter by title, author, or rating. section 10.2 section 10.3

The query contains an empty match_all object, so every available document matches. Results receive a score of 1.0 by default, and a boost can change that score. section 10.3.1

Retrieve every book

GET books/_search { "query": { "match_all": {} } } The books index returns all available documents. To boost every result, use "boost": 2 inside the match_all object. section 10.3.1

Choose the form that fits the request:

  • Use GET books/_search without a request body when the default boost of 1 is sufficient; Elasticsearch treats it as match_all. section 10.3.2 section 2.2.2
  • Provide the explicit query body when you need to set a boost or make the match-all behavior visible in a larger query. section 2.2.2 section 10.3.1
  • Treat match_all as a broad retrieval operation rather than criteria-based searching; filtered and relevance-focused queries serve more selective needs. section 2.2.2 section 10.13
Listing 10.1 Fetching all documents using match_all
GET books/_search
{
  "query": {
    "match_all": { }    #1
  }
}

Shows the minimal REST request for explicitly fetching every document from the books index. section 10.3.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains construction, default scoring, boosting, and the bodyless shorthand, without descending into execution internals.
Examples
Demonstrates retrieving books with explicit JSON, omitting the body, and boosting every result.
What it assumes
Assumes an indexed collection and familiarity with the basic _search endpoint; teaches the query syntax from a simple retrieval scenario.
What you can do after
Apply it via the Elasticsearch _search API to retrieve all documents or assign a shared boosted score.
How it connects
Connects match_all with the _search API, full-text queries, relevance scores, and boost parameters.

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.