January 2020
Intermediate to advanced
640 pages
16h 56m
English
As you might expect from a product whose primary job is searching within documents, Elasticsearch supports a plethora of different query types, ranging from keyword-based searches to complex geospatial or time-based queries. Unfortunately, the syntax for specifying queries varies slightly, depending on the type of query that we wish to perform.
It turns out that, for our particular use case, we can get away with using the same query syntax for both keyword- and phrase-based queries. All we need to do is convert the QueryType provided by the caller into an Elasticsearch-specific value that we can plug into a predefined search template. To achieve this, the indexer implementation makes use of the switch block ...