9 Term-level search

 

This chapter covers

  • Understanding term-level queries
  • Term-level queries in action

Term-level searches are designed to work with structured data such as numbers, dates, IP addresses, enumerations, keyword types, and so on. They help us find the answers but don’t look at relevance. That is, they search for exact matches rather than how well documents match the query. One fundamental difference between these queries and full-text searches is that term-level queries do not undergo text analysis.

This chapter focuses on term-level searches in detail and works through the various query types with examples. Let’s begin with an overview and then look at specific queries.

NOTE

The code for this chapter is available on GitHub (http://mng.bz/Gyw8) and on the book’s website (https://www.manning.com/books/elasticsearch-in-action-second-edition).

9.1 Overview of term-level search

Term-level search is structured: queries return results in exact matches. They search for structured data such as dates, numbers, and ranges. With this type of search, we don’t care how well the results match (how well documents correspond to the query), just that the query returns data if the query is matched. Hence, we do not expect a relevancy score associated with the results of a term-level search.

A term-level search produces a yes or no binary option similar to a database’s WHERE clause. Query results are fetched if the condition is met; otherwise, the query doesn’t return any results.

9.1.1 Term-level queries are not analyzed

9.1.2 Term-level query example

9.2 The term query

9.2.1 The term query on text fields

9.2.2 Example term query

9.2.3 Shortened term-level queries

9.3.1 Example terms query