liveBook · Manning

Keyword query

As explained in Elasticsearch in Action, Second Edition

A search query is a request that evaluates query criteria against indexed documents to retrieve matching results.

A keyword query asks Elasticsearch to evaluate criteria against indexed documents and return matching results. It uses the _search endpoint and can be written with Query DSL or query requests. Text searches may return results ordered by relevance score rather than exact equality. section 8.1 section 8.4

When the target field is full text, Elasticsearch analyzes the query with the field’s analyzer, tokenizes and normalizes it, then matches the resulting tokens in the inverted index. This supports roots, synonyms, and spelling variations. section 3.1.3

Search for several words in a book title

A match query for “Java Complete Guide” searches the title field and highlights matching text. Its default OR behavior can return documents containing any word; set operator to AND when every word must appear. section 10.5.4

Listing 10.5 A match query for a set of words
GET books/_search
{
  "query": {
    "match": {
      "title": {
        "query": "Java Complete Guide"
      }
    }
  },
  "highlight": {
    "fields": {
      "title": {}
    }
  }
}

Use this runnable request to search the books index for title terms and highlight the matches. section 10.5.4

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains analysis, token matching, relevance, and Boolean operators, but defers detailed precision and recall treatment.
Examples
Demonstrates a books index, a Java Complete Guide title search, highlighting, and explicit OR and AND operators.
What it assumes
Assumes indexed fields and Elasticsearch access, while introducing REST invocation, Query DSL, analysis, and relevance from fundamentals.
What you can do after
Apply it via the Elasticsearch _search endpoint with Query DSL, choosing token matching and Boolean behavior for the search need.
How it connects
Connects full-text search, term-level queries, Query DSL, analyzers, inverted indexes, relevance, precision, and recall.

Also explained in

Compare how 3 books explain keyword query →

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.