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
