12 Advanced search

 

This chapter covers

  • Geo data types
  • Searching locations and addresses with geoqueries
  • Using geo_shape to search for 2D shapes
  • Using span queries to work with low-level positional tokens
  • Specialized queries such as percolators

Earlier chapters have covered searching data using term-level and full-text queries. We’ve also looked at advanced queries like bool, boosting, and others. To continue building on what we’ve discussed and advance the query landscape, this chapter introduces several kinds of specialized queries.

We begin by looking at searches aimed at geolocations. Common use cases involving geoqueries include searching nearby restaurants for a delivery order, finding directions to a friend’s house, locating popular schools within a 10 km range, and so on. Elasticsearch has first-class support for satisfying such location-related searches. It also provides several geospatial queries: geo_bounding_box, geo_ distance, and geo_shape.

Next, we examine how to search two-dimensional (2D) shapes using shape queries. Design engineers, game developers, and others can search in an index of 2D shapes. Then we look at low-level positional queries called span queries. Although full-text and term-level leaf queries help us search for data, they can’t find words in a particular order, their position, the exact (or approximate) distance between words, and so on. This is where span queries come into play.

12.1 Introducing location search

12.1.1 The bounding_box query

12.1.2 The geo_distance query

12.1.3 The geo_shape query

12.2 Geospatial data types

12.2.1 The geo_point data type

12.2.2 The geo_shape data type

12.3 Geospatial queries