chapter nine

9 Term-level search

 

This chapter covers

  • Overview of term-level queries
  • Term-level queries in action

Term-level search is designed to work with structured data such as numbers, dates, IP address, enumerations, keyword types, and others. We use term-level queries to find an exact match. This short chapter solely focuses on understanding the term-level search in detail and works through the various query types with examples.

The source code for this chapter is available on my GitHub page here:

Let’s begin with an overview of term-level searches and then we will look at specific queries.

9.1 Overview of term-level search

The term-level search is a structured search where the 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 about how well the results match (like how well the documents correspond to the query) but that it returns the data (or not) if the query is matched. Hence, we do not expect a relevancy score associated with the results from a term-level search.

The term-level search produces a Yes or No binary option similar to the database’s WHERE clause. The basic idea for this kind of search is that the results are binary: the query results are fetched if the condition is met; otherwise, it returns none if the condition fails.

9.1.1 Term-level queries are not analyzed

9.2 Term queries

9.2.1 Term queries on text fields

9.2.2 Example: Applying a term query on a movie’s title

9.2.3 Shortened term-level queries

9.3 Terms queries

9.3.1 Terms lookup

9.4 IDs queries

9.5 Exists queries

9.5.1 Non existent field check

9.6 Range queries

9.6.1 Range queries with data math

9.7 Wildcard queries

9.7.1 Expensive queries

9.8 Prefix queries

9.8.1 Speeding up prefix queries

9.9 Fuzzy queries

9.10 Summary