A match query searches unstructured text fields for supplied words and returns matching documents with relevance scores. Use it when a bookstore reader searches a title or author rather than an exact structured value. section 10.0 section 10.5
Listing 10.4 Searching for Java books
GET books/_search
{
"query": {
"match": { #1
"title": "Java" #2
}
}
}
Search for Java in the title field by placing a match clause inside the _search request's query object. section 10.5.2 section 10.5.1
The query value can contain one or more words in any case. Match queries analyze text with the analyzer used at indexing unless a different search analyzer is explicitly configured; with the standard analyzer, JAVA, java, and jaVA produce the same result. section 10.5.1 section 10.5.3
Extend a match query when the search requirement changes:
- Add fuzziness to tolerate character mistakes, such as matching Komputer with Computer at fuzziness 1. section 2.3.8
- Place it in a bool must clause with match_phrase, range, term, or other leaf queries to require several conditions. section 2.5.2 section 11.3.3
- Expect query context to score matches; placing it in a bool filter removes relevance scoring when only match status matters. section 8.4.2
Author search
To find books by Joshua Bloch, match the author field against Joshua. Elasticsearch analyzes the request, searches its inverted indexes, retrieves matching documents, and returns the result. A shortened value such as josh needs a prefix query instead; prefix queries are term-level and require lowercase input. section 2.3.1
