Repository: blevesearch/bleve
Pull request #1671 (2022-04-06 15:24:31)

Updating integration tests for the geojson shapes.


Patch:
diff --git a/search/searcher/search_geoshape.go b/search/searcher/search_geoshape.go
index b26cbde1..871777e7 100644
--- a/search/searcher/search_geoshape.go
+++ b/search/searcher/search_geoshape.go
@@ -16,7 +16,6 @@ package searcher
 
 import (
 	"bytes"
-	"fmt"
 
 	"github.com/blevesearch/bleve/v2/geo"
 	"github.com/blevesearch/bleve/v2/search"
@@ -26,29 +25,35 @@ import (
 func NewGeoShapeSearcher(indexReader index.IndexReader, shape index.GeoJSON,
 	relation string, field string, boost float64,
 	options search.SearcherOptions) (search.Searcher, error) {
+	var err error
+	var spatialPlugin index.SpatialAnalyzerPlugin
 
+	// check for the spatial plugin from the index.
 	if sr, ok := indexReader.(index.SpatialIndexPlugin); ok {
-		tp, err := sr.GetSpatialAnalyzerPlugin("s2")
-		if err == nil {
-			// obtain the query tokens.
-			terms := tp.GetQueryTokens(shape)
-			mSearcher, err := NewMultiTermSearcher(indexReader, terms,
-				field, boost, options, false)
-			if err != nil {
-				return nil, err
-			}
+		spatialPlugin, _ = sr.GetSpatialAnalyzerPlugin("s2")
+	}
 
-			dvReader, err := indexReader.DocValueReader([]string{field})
-			if err != nil {
-				return nil, err
-			}
+	if spatialPlugin == nil {
+		// fallback to the default spatial plugin(s2).
+		spatialPlugin = geo.GetSpatialAnalyzerPlugin("s2")
+	}
 
-			return NewFilteringSearcher(mSearcher,
-				buildRelationFilterOnShapes(dvReader, field, relation, shape)), nil
-		}
+	// obtain the query tokens.
+	terms := spatialPlugin.GetQueryTokens(shape)
+	mSearcher, err := NewMultiTermSearcher(indexReader, terms,
+		field, boost, options, false)
+	if err != nil {
+		return nil, err
 	}
 
-	return nil, fmt.Errorf("no SpatialIndexPlugin implementation found")
+	dvReader, err := indexReader.DocValueReader([]string{field})
+	if err != nil {
+		return nil, err
+	}
+
+	return NewFilteringSearcher(mSearcher,
+		buildRelationFilterOnShapes(dvReader, field, relation, shape)), nil
+
 }
 
 func buildRelationFilterOnShapes(dvReader index.DocValueReader, field string,


Test patch:
diff --git a/test/tests/geoshapes/data/circle_halairport.json b/test/tests/geoshapes/data/circle_halairport.json
new file mode 100644
index 00000000..d7e6a13b
--- /dev/null
+++ b/test/tests/geoshapes/data/circle_halairport.json
@@ -0,0 +1,14 @@
+{
+  "name": "hal airpork circular region",
+  "city": "bangalore",
+  "type": "geoshapes",
+  "description": "circle covering the hal airport",
+  "region": {
+    "type": "Circle",
+    "coordinates": [
+      77.6698637008667,
+      12.951865687866821
+    ],
+    "radius": "2.4km"
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/envelope_brockwell_park.json b/test/tests/geoshapes/data/envelope_brockwell_park.json
new file mode 100644
index 00000000..c868f04a
--- /dev/null
+++ b/test/tests/geoshapes/data/envelope_brockwell_park.json
@@ -0,0 +1,19 @@
+{
+  "name": "brockwell park envelope",
+  "city": "london",
+  "type": "geoshapes",
+  "description": "brockwell park envelope",
+  "region": {
+    "type": "envelope",
+    "coordinates": [
+      [
+        -0.11278152465820314,
+        51.44579626059569
+      ],
+      [
+        -0.10037899017333984,
+        51.45566490761856
+      ]
+    ]
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/geometrycollection_tvm.json b/test/tests/geoshapes/data/geometrycollection_tvm.json
new file mode 100644
index 00000000..5b08c905
--- /dev/null
+++ b/test/tests/geoshapes/data/geometrycollection_tvm.json
@@ -0,0 +1,165 @@
+{
+    "name": "geometrycollection comprised of various shapes",
+    "city": "bangalore",
+    "type": "geoshapes",
+    "description": "geometrycollection comprised of various shapes",
+    "region": {
+        "type": "geometrycollection",
+        "geometries": [
+            {
+                "type": "point",
+                "coordinates": [
+                    76.92815780639648,
+                    8.525851789596233
+                ]
+            },
+            {
+                "type": "LineString",
+                "coordinates": [
+                    [
+                        76.92867279052734,
+                        8.490369393806219
+                    ],
+                    [
+                        76.94377899169922,
+                        8.494104537551882
+                    ]
+                ]
+            },
+            {
+                "type": "polygon",
+                "coordinates": [
+                    [
+                        [
+                            76.92815780639648,
+                            8.525851789596233
+                        ],
+                        [
+                            76.92060470581055,
+                            8.520504174874656
+                        ],
+                        [
+                            76.92206382751465,
+                            8.519061154914393
+                        ],
+                        [
+                            76.92824363708496,
+                            8.519061154914393
+                        ],
+                        [
+                            76.92970275878906,
+                            8.523475081176768
+                        ],
+                        [
+                            76.92815780639648,
+                            8.525851789596233
+                        ]
+                    ]
+                ]
+            },
+            {
+                "type": "multipoint",
+                "coordinates": [
+                    [
+                        76.90670013427733,
+                        8.497839644932787
+                    ],
+                    [
+                        76.94137573242188,
+                        8.485275957394883
+                    ]
+                ]
+            },
+            {
+                "type": "multiLineString",
+                "coordinates": [
+                    [
+                        [
+                            76.89322471618651,
+                            8.521522773921424
+                        ],
+                        [
+                            76.89648628234863,
+                            8.518042549311815
+                        ]
+                    ],
+                    [
+                        [
+                            76.9068717956543,
+                            8.494783650690053
+                        ],
+                        [
+                            76.93296432495117,
+                            8.468552033040881
+                        ]
+                    ]
+                ]
+            },
+            {
+                "type": "multipolygon",
+                "coordinates": [
+                    [
+                        [
+                            [
+                                76.90249443054199,
+                                8.546138091708775
+                            ],
+                            [
+                                76.89983367919922,
+                                8.541300033890494
+                            ],
+                            [
+                                76.90498352050781,
+                                8.53985709248573
+                            ],
+                            [
+                                76.90858840942383,
+                                8.54520443620746
+                            ],
+                            [
+                                76.90712928771973,
+                                8.548090273095957
+                            ],
+                            [
+                                76.90249443054199,
+                                8.546138091708775
+                            ]
+                        ]
+                    ],
+                    [
+                        [
+                            [
+                                76.88326835632324,
+                                8.564131732621458
+                            ],
+                            [
+                                76.88429832458496,
+                                8.555729147617923
+                            ],
+                            [
+                                76.88893318176268,
+                                8.552079482230221
+                            ],
+                            [
+                                76.89339637756348,
+                                8.55369212938781
+                            ],
+                            [
+                                76.89494132995605,
+                                8.56133089156368
+                            ],
+                            [
+                                76.89116477966309,
+                                8.566423314514562
+                            ],
+                            [
+                                76.88326835632324,
+                                8.564131732621458
+                            ]
+                        ]
+                    ]
+                ]
+            }
+        ]
+    }
+}
diff --git a/test/tests/geoshapes/data/linestring_putney_bridge.json b/test/tests/geoshapes/data/linestring_putney_bridge.json
new file mode 100644
index 00000000..cf82a36e
--- /dev/null
+++ b/test/tests/geoshapes/data/linestring_putney_bridge.json
@@ -0,0 +1,19 @@
+{
+    "name": "linestring for putney bridge",
+    "city": "london",
+    "type": "geoshapes",
+    "description": "linestring for putney bridge",
+    "region": {
+        "type": "linestring",
+        "coordinates": [
+            [
+                -0.21183013916015625,
+                51.46791083061189
+            ],
+            [
+                -0.21431922912597656,
+                51.465504685939706
+            ]
+        ]
+    }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/multilinestring_old_airport_road.json b/test/tests/geoshapes/data/multilinestring_old_airport_road.json
new file mode 100644
index 00000000..b6fff04f
--- /dev/null
+++ b/test/tests/geoshapes/data/multilinestring_old_airport_road.json
@@ -0,0 +1,45 @@
+{
+    "name": "road routes",
+    "city": "bangalore",
+    "type": "geoshapes",
+    "description": "multilinestrings approximating the roads indiranagar 100ft and old airport port road",
+    "region": {
+        "type": "multilinestring",
+        "coordinates": [
+            [
+                [
+                    77.64081001281738,
+                    12.983398626256326
+                ],
+                [
+                    77.64166831970213,
+                    12.960648472679763
+                ],
+                [
+                    77.64192581176758,
+                    12.960564828571133
+                ],
+                [
+                    77.66990661621094,
+                    12.958390071883693
+                ],
+                [
+                    77.67016410827637,
+                    12.958055492245812
+                ],
+                [
+                    77.68106460571289,
+                    12.954626025039444
+                ],
+                [
+                    77.68149375915527,
+                    12.954542378907867
+                ],
+                [
+                    77.7011489868164,
+                    12.957219041184294
+                ]
+            ]
+        ]
+    }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/multipoint_blr_stadiums.json b/test/tests/geoshapes/data/multipoint_blr_stadiums.json
new file mode 100644
index 00000000..b21fb1d3
--- /dev/null
+++ b/test/tests/geoshapes/data/multipoint_blr_stadiums.json
@@ -0,0 +1,23 @@
+{
+  "name": "multipoints for stadiums",
+  "city": "bangalore",
+  "type": "geoshapes",
+  "description": "contains 3 points",
+  "region": {
+    "type": "multipoint",
+    "coordinates": [
+      [
+        77.5929594039917,
+        12.969347306502671
+      ],
+      [
+        77.6004695892334,
+        12.979007674139009
+      ],
+      [
+        77.60068416595459,
+        12.961735843534306
+      ]
+    ]
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/multipolygon_london_parks.json b/test/tests/geoshapes/data/multipolygon_london_parks.json
new file mode 100644
index 00000000..659773a2
--- /dev/null
+++ b/test/tests/geoshapes/data/multipolygon_london_parks.json
@@ -0,0 +1,87 @@
+{
+  "name": "london parks as multipolygon",
+  "city": "london",
+  "type": "geoshapes",
+  "description": "multipolygon with london",
+  "region": {
+    "type": "MultiPolygon",
+    "coordinates": [
+      [
+        [
+          [
+            -0.163421630859375,
+            51.531600743186644
+          ],
+          [
+            -0.15277862548828125,
+            51.52455221546295
+          ],
+          [
+            -0.14556884765625,
+            51.524979430024345
+          ],
+          [
+            -0.14591217041015625,
+            51.536085601784755
+          ],
+          [
+            -0.15895843505859375,
+            51.53693981046689
+          ],
+          [
+            -0.163421630859375,
+            51.531600743186644
+          ]
+        ]
+      ],
+      [
+        [
+          [
+            -0.1902008056640625,
+            51.5091698216777
+          ],
+          [
+            -0.1888275146484375,
+            51.50147667659363
+          ],
+          [
+            -0.15071868896484375,
+            51.503186376638006
+          ],
+          [
+            -0.1599884033203125,
+            51.51322956905176
+          ],
+          [
+            -0.1902008056640625,
+            51.5091698216777
+          ]
+        ]
+      ],
+      [
+        [
+          [
+            -0.16582489013671875,
+            51.4811690848672
+          ],
+          [
+            -0.1635932922363281,
+            51.474861202507434
+          ],
+          [
+            -0.14883041381835938,
+            51.47764105478667
+          ],
+          [
+            -0.14951705932617188,
+            51.48352095330697
+          ],
+          [
+            -0.16582489013671875,
+            51.4811690848672
+          ]
+        ]
+      ]
+    ]
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/point_museum_of_london.json b/test/tests/geoshapes/data/point_museum_of_london.json
new file mode 100644
index 00000000..1a74a2eb
--- /dev/null
+++ b/test/tests/geoshapes/data/point_museum_of_london.json
@@ -0,0 +1,13 @@
+{
+  "name": "geopoint for the museum of london",
+  "city": "london",
+  "type": "geoshapes",
+  "description": "geopoint for the museum of london",
+  "region": {
+    "type": "point",
+    "coordinates": [
+      -0.09613037109375,
+      51.51803669675129
+    ]
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/data/polygon_cubbonpark.json b/test/tests/geoshapes/data/polygon_cubbonpark.json
new file mode 100644
index 00000000..c4865a00
--- /dev/null
+++ b/test/tests/geoshapes/data/polygon_cubbonpark.json
@@ -0,0 +1,45 @@
+{
+  "name": "cubbon park polygon",
+  "city": "bangalore",
+  "type": "geoshapes",
+  "description": "polygon inside cubbon park",
+  "region": {
+    "type": "Polygon",
+    "coordinates": [
+      [
+        [
+          77.58894681930542,
+          12.976498523818783
+        ],
+        [
+          77.58677959442139,
+          12.974533005048169
+        ],
+        [
+          77.5879168510437,
+          12.971333776381767
+        ],
+        [
+          77.58849620819092,
+          12.96800904416803
+        ],
+        [
+          77.59371042251587,
+          12.972128359891645
+        ],
+        [
+          77.59512662887573,
+          12.973842978816679
+        ],
+        [
+          77.59253025054932,
+          12.976853988320428
+        ],
+        [
+          77.58894681930542,
+          12.976498523818783
+        ]
+      ]
+    ]
+  }
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/mapping.json b/test/tests/geoshapes/mapping.json
new file mode 100644
index 00000000..3e742029
--- /dev/null
+++ b/test/tests/geoshapes/mapping.json
@@ -0,0 +1,36 @@
+{
+  "types": {
+    "geoshapes": {
+      "properties": {
+        "name": {
+          "fields": [
+            {
+              "include_term_vectors": true,
+              "include_in_all": true,
+              "index": true,
+              "store": true,
+              "analyzer": "keyword",
+              "type": "text"
+            }
+          ],
+          "dynamic": true,
+          "enabled": true
+        },
+        "region": {
+          "fields": [
+            {
+              "include_term_vectors": true,
+              "include_in_all": true,
+              "index": true,
+              "store": true,
+              "type": "geoshape"
+            }
+          ],
+          "dynamic": true,
+          "enabled": true
+        }
+      }
+    }
+  },
+  "default_type": "geoshapes"
+}
\ No newline at end of file
diff --git a/test/tests/geoshapes/searches.json b/test/tests/geoshapes/searches.json
new file mode 100644
index 00000000..9b0d4ee0
--- /dev/null
+++ b/test/tests/geoshapes/searches.json
@@ -0,0 +1,1436 @@
+[
+  {
+    "comment": "search with a circular shape within cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "Circle",
+            "coordinates": [
+              77.59092092514038,
+              12.975494856600474
+            ],
+            "radius": "0.1km"
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a circular shape within cubbon park polygon, (circle doesn't fully contained within)",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              77.59092092514038,
+              12.975494856600474
+            ],
+            "radius": "150m"
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 0,
+      "hits": []
+    }
+  },
+  {
+    "comment": "search with a polygon that contains the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "Polygon",
+            "coordinates": [
+              [
+                [
+                  77.58617877960205,
+                  12.9772303619447
+                ],
+                [
+                  77.58630752563477,
+                  12.966419848296587
+                ],
+                [
+                  77.59802341461182,
+                  12.968887279637073
+                ],
+                [
+                  77.5989246368408,
+                  12.980304058548604
+                ],
+                [
+                  77.58617877960205,
+                  12.9772303619447
+                ]
+              ]
+            ]
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a multipolygon that intersects the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multipolygon",
+            "coordinates": [
+              [
+                [
+                  [
+                    77.58268117904663,
+                    12.980513152175025
+                  ],
+                  [
+                    77.58147954940794,
+                    12.977983107483992
+                  ],
+                  [
+                    77.58708000183104,
+                    12.97886130773254
+                  ],
+                  [
+                    77.58268117904663,
+                    12.980513152175025
+                  ]
+                ]
+              ],
+              [
+                [
+                  [
+                    77.5864577293396,
+                    12.97762764459667
+                  ],
+                  [
+                    77.58879661560059,
+                    12.975076660730531
+                  ],
+                  [
+                    77.59115695953369,
+                    12.979216768855913
+                  ],
+                  [
+                    77.5864577293396,
+                    12.97762764459667
+                  ]
+                ]
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with multilinestrings that intersects the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multilinestring",
+            "coordinates": [
+              [
+                [
+                  77.58761644363403,
+                  12.974302996517075
+                ],
+                [
+                  77.59319543838501,
+                  12.978401298465434
+                ]
+              ],
+              [
+                [
+                  77.5947618484497,
+                  12.98500862259466
+                ],
+                [
+                  77.59808778762817,
+                  12.983565899088745
+                ]
+              ],
+              [
+                [
+                  77.60109186172485,
+                  12.973529329896703
+                ],
+                [
+                  77.59943962097168,
+                  12.970225537247586
+                ]
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with multilinestrings that aren't contained within the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multilinestring",
+            "coordinates": [
+              [
+                [
+                  77.58761644363403,
+                  12.974302996517075
+                ],
+                [
+                  77.59319543838501,
+                  12.978401298465434
+                ]
+              ],
+              [
+                [
+                  77.5947618484497,
+                  12.98500862259466
+                ],
+                [
+                  77.59808778762817,
+                  12.983565899088745
+                ]
+              ],
+              [
+                [
+                  77.60109186172485,
+                  12.973529329896703
+                ],
+                [
+                  77.59943962097168,
+                  12.970225537247586
+                ]
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 0,
+      "hits": []
+    }
+  },
+  {
+    "comment": "search with multilinestrings that are all contained within the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multilinestring",
+            "coordinates": [
+              [
+                [
+                  77.59107112884521,
+                  12.975243939162915
+                ],
+                [
+                  77.59190797805786,
+                  12.973842978816679
+                ]
+              ],
+              [
+                [
+                  77.58954763412476,
+                  12.970685561638497
+                ],
+                [
+                  77.59117841720581,
+                  12.971835618893842
+                ]
+              ],
+              [
+                [
+                  77.58851766586304,
+                  12.973152950670608
+                ],
+                [
+                  77.58937597274779,
+                  12.972212000113458
+                ]
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with point that is contained within the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "Point",
+            "coordinates": [
+              77.59107112884521,
+              12.975243939162915
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with an envelope that is within the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "Envelope",
+            "coordinates": [
+              [
+                77.59158611297607,
+                12.9720028995062035
+              ],
+              [
+                77.59263753890991,
+                12.973173860642571
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with an envelope that contains the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "Envelope",
+            "coordinates": [
+              [
+                77.57969856262207,
+                12.9641614998626
+              ],
+              [
+                77.60295867919922,
+                12.989336742847172
+              ]
+            ]
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a geometrycollection that is within the cubbon park polygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "geometrycollection",
+            "geometries": [
+              {
+                "type": "point",
+                "coordinates": [
+                  77.59158611297607,
+                  12.972002899506203
+                ]
+              },
+              {
+                "type": "LineString",
+                "coordinates": [
+                  [
+                    77.58851766586304,
+                    12.973152950670608
+                  ],
+                  [
+                    77.58937597274779,
+                    12.972212000113458
+                  ]
+                ]
+              },
+              {
+                "type": "polygon",
+                "coordinates": [
+                  [
+                    [
+                      77.59055614471436,
+                      12.974721193688106
+                    ],
+                    [
+                      77.58954763412476,
+                      12.97350841995465
+                    ],
+                    [
+                      77.59141445159912,
+                      12.973382960265356
+                    ],
+                    [
+                      77.59055614471436,
+                      12.974721193688106
+                    ]
+                  ]
+                ]
+              }
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a polygon that intersects the hal airport region",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "polygon",
+            "coordinates": [
+              [
+                [
+                  77.67934799194336,
+                  12.938147195017896
+                ],
+                [
+                  77.66793251037598,
+                  12.930492951786736
+                ],
+                [
+                  77.67711639404297,
+                  12.922127390141315
+                ],
+                [
+                  77.67934799194336,
+                  12.938147195017896
+                ]
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "circle_halairport"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a linestring that intersects the hal airport and cubbon park region",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "linestring",
+            "coordinates": [
+              [
+                77.59042739868164,
+                12.973529329896703
+              ],
+              [
+                77.65892028808594,
+                12.950109093741462
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 2,
+      "hits": [
+        {
+          "id": "circle_halairport"
+        },
+        {
+          "id": "polygon_cubbonpark"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with an envelope within the circle_halairport",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "envelope",
+            "coordinates": [
+              [
+                77.65625953674316,
+                12.943249893344905
+              ],
+              [
+                77.68355369567871,
+                12.945843027882455
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "circle_halairport"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a circle which intersects the road multilinestring and the hal circle",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              77.68132209777832,
+              12.954918786278716
+            ],
+            "radius": "50m"
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 2,
+      "hits": [
+        {
+          "id": "circle_halairport"
+        },
+        {
+          "id": "multilinestring_old_airport_road"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a polygon which intersects the road multilinestring",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "polygon",
+            "coordinates": [
+              [
+                [
+                  77.64102458953856,
+                  12.97751264178902
+                ],
+                [
+                  77.64109969139099,
+                  12.975317123441693
+                ],
+                [
+                  77.64338493347168,
+                  12.976728530319054
+                ],
+                [
+                  77.64102458953856,
+                  12.97751264178902
+                ]
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multilinestring_old_airport_road"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a linestring which intersects the road multilinestring",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "linestring",
+            "coordinates": [
+              [
+                77.63969421386717,
+                12.978265386473618
+              ],
+              [
+                77.64354586601257,
+                12.978453572288663
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multilinestring_old_airport_road"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with an envelope which intersects the road multilinestring",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "envelope",
+            "coordinates": [
+              [
+                77.64100313186644,
+                12.95902786307307
+              ],
+              [
+                77.6419472694397,
+                12.96069029472353
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multilinestring_old_airport_road"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with multipoint which are contained within the multipolygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multipoint",
+            "coordinates": [
+              [
+                -0.14797210693359375,
+                51.52615424940099
+              ],
+              [
+                -0.16857147216796875,
+                51.50863561745838
+              ],
+              [
+                -0.15535354614257812,
+                51.48010001366223
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multipolygon_london_parks"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with multilinestring that are contained within the multipolygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multilinestring",
+            "coordinates": [
+              [
+                [
+                  -0.17063140869140625,
+                  51.50884929989774
+                ],
+                [
+                  -0.15655517578125,
+                  51.5072466571743
+                ]
+              ],
+              [
+                [
+                  -0.16222000122070312,
+                  51.47988619641402
+                ],
+                [
+                  -0.15466690063476562,
+                  51.48074145939243
+                ]
+              ],
+              [
+                [
+                  -0.15844345092773438,
+                  51.53245503603458
+                ],
+                [
+                  -0.15123367309570312,
+                  51.53170753066937
+                ]
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multipolygon_london_parks"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with multilinestring out of which one isn't contained within the multipolygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "multilinestring",
+            "coordinates": [
+              [
+                [
+                  -0.17063140869140625,
+                  51.50884929989774
+                ],
+                [
+                  -0.15655517578125,
+                  51.5072466571743
+                ]
+              ],
+              [
+                [
+                  -0.16222000122070312,
+                  51.47988619641402
+                ],
+                [
+                  -0.15466690063476562,
+                  51.48074145939243
+                ]
+              ],
+              [
+                [
+                  -0.15844345092773438,
+                  51.53245503603458
+                ],
+                [
+                  -0.15123367309570312,
+                  51.53170753066937
+                ]
+              ],
+              [
+                [
+                  -0.08651733398437499,
+                  51.51013137348817
+                ],
+                [
+                  -0.08909225463867188,
+                  51.50543026060529
+                ]
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 0,
+      "hits": []
+    }
+  },
+  {
+    "comment": "search with a geometrycollection that contains the london_parks_multipolygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "geometrycollection",
+            "geometries": [
+              {
+                "type": "multipolygon",
+                "coordinates": [
+                  [
+                    [
+                      [
+                        -0.19517898559570312,
+                        51.51344322994464
+                      ],
+                      [
+                        -0.19277572631835938,
+                        51.49292721420451
+                      ],
+                      [
+                        -0.14110565185546875,
+                        51.49773648412071
+                      ],
+                      [
+                        -0.14471054077148438,
+                        51.51889124411907
+                      ],
+                      [
+                        -0.19517898559570312,
+                        51.51344322994464
+                      ]
+                    ]
+                  ],
+                  [
+                    [
+                      [
+                        -0.16925811767578122,
+                        51.48373475351443
+                      ],
+                      [
+                        -0.16925811767578122,
+                        51.47004951935931
+                      ],
+                      [
+                        -0.14608383178710938,
+                        51.472722739318336
+                      ],
+                      [
+                        -0.14453887939453125,
+                        51.48758298584306
+                      ],
+                      [
+                        -0.16925811767578122,
+                        51.48373475351443
+                      ]
+                    ]
+                  ]
+                ]
+              },
+              {
+                "type": "LineString",
+                "coordinates": [
+                  [
+                    77.58851766586304,
+                    12.973152950670608
+                  ],
+                  [
+                    77.58937597274779,
+                    12.972212000113458
+                  ]
+                ]
+              },
+              {
+                "type": "polygon",
+                "coordinates": [
+                  [
+                    [
+                      -0.17337799072265625,
+                      51.54323910441573
+                    ],
+                    [
+                      -0.1668548583984375,
+                      51.51889124411907
+                    ],
+                    [
+                      -0.09286880493164062,
+                      51.53341609632549
+                    ],
+                    [
+                      -0.17337799072265625,
+                      51.54323910441573
+                    ]
+                  ]
+                ]
+              }
+            ]
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multipolygon_london_parks"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a circle that intersects with one of the polygons in the multipolygon_london_parks",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              -0.14265060424804688,
+              51.53298896092339
+            ],
+            "radius": "550m"
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multipolygon_london_parks"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with a circle that contains london museum geopoint",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              -0.09115219116210938,
+              51.516487788780005
+            ],
+            "radius": "1050m"
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "point_museum_of_london"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with brockwell park polygon that is contained within brockwell park envelope",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "polygon",
+            "coordinates": [
+              [
+                [
+                  -0.11149406433105469,
+                  51.454942883825744
+                ],
+                [
+                  -0.11230945587158205,
+                  51.45218839188088
+                ],
+                [
+                  -0.11136531829833984,
+                  51.450530268053605
+                ],
+                [
+                  -0.1117086410522461,
+                  51.44873835686053
+                ],
+                [
+                  -0.11016368865966797,
+                  51.446010237625224
+                ],
+                [
+                  -0.10497093200683594,
+                  51.446705656046376
+                ],
+                [
+                  -0.10192394256591797,
+                  51.4490058107573
+                ],
+                [
+                  -0.1007223129272461,
+                  51.45085119994589
+                ],
+                [
+                  -0.10188102722167967,
+                  51.45218839188088
+                ],
+                [
+                  -0.10681629180908203,
+                  51.45368600035086
+                ],
+                [
+                  -0.10715961456298828,
+                  51.453338345620416
+                ],
+                [
+                  -0.11149406433105469,
+                  51.454942883825744
+                ]
+              ]
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "envelope_brockwell_park"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with point that is contained within brockwell park envelope",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "point",
+            "coordinates": [
+              -0.10074377059936523,
+              51.450824455707696
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "envelope_brockwell_park"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with linestring that intersects the putney bridge",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "LineString",
+            "coordinates": [
+              [
+                -0.2171945571899414,
+                51.46876631814087
+              ],
+              [
+                -0.2064228057861328,
+                51.464943233925986
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "linestring_putney_bridge"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search with polygon that contains the blr stadiums/multipoint",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "polygon",
+            "coordinates": [
+              [
+                [
+                  77.60107040405273,
+                  12.981349524921757
+                ],
+                [
+                  77.59270191192627,
+                  12.969180024104505
+                ],
+                [
+                  77.60089874267577,
+                  12.961024870820744
+                ],
+                [
+                  77.60107040405273,
+                  12.981349524921757
+                ]
+              ]
+            ]
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "multipoint_blr_stadiums"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search a point that is within the multipolygon of the geometrycollection",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "point",
+            "coordinates": [
+              76.88919067382812,
+              8.556238400473156
+            ]
+          },
+          "relation": "contains"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "geometrycollection_tvm"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search an envelope that intersects with the polygon of the geometrycollection",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "envelope",
+            "coordinates": [
+              [
+                76.91880226135254,
+                8.515665792358828
+              ],
+              [
+                76.92523956298828,
+                8.525427378462332
+              ]
+            ]
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "geometrycollection_tvm"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search a circle that intersects with the linestring of the geometrycollection",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              76.91305160522461,
+              8.477890354619287
+            ],
+            "radius": "1mi"
+          },
+          "relation": "intersects"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "geometrycollection_tvm"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search a circle that contains the entire geometrycollection",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              76.93622589111328,
+              8.501574715933401
+            ],
+            "radius": "10mi"
+          },
+          "relation": "within"
+        }
+      }
+    },
+    "result": {
+      "total_hits": 1,
+      "hits": [
+        {
+          "id": "geometrycollection_tvm"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search a polygon that contains the entire geometrycollection, circle, multilinestring, polygon, multipoint",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              77.71728515624999,
+              12.060809058367294
+            ],
+            "radius": "1000mi"
+          },
+          "relation": "within"
+        }
+      },
+      "sort": ["-_id"]
+    },
+    "result": {
+      "total_hits": 5,
+      "hits": [
+        {
+          "id": "polygon_cubbonpark"
+        },
+        {
+          "id": "multipoint_blr_stadiums"
+        },
+        {
+          "id": "multilinestring_old_airport_road"
+        },
+        {
+          "id": "geometrycollection_tvm"
+        },
+        {
+          "id": "circle_halairport"
+        }
+      ]
+    }
+  },
+  {
+    "comment": "search circle that contains the envelope, linestring, point, multipolygon",
+    "search": {
+      "from": 0,
+      "size": 10,
+      "query": {
+        "geometry": {
+          "shape": {
+            "type": "circle",
+            "coordinates": [
+              -0.23277282714843747,
+              51.45828549061808
+            ],
+            "radius": "1000mi"
+          },
+          "relation": "within"
+        }
+      },
+      "sort": ["-_id"]
+    },
+    "result": {
+      "total_hits": 4,
+      "hits": [
+        {
+          "id": "point_museum_of_london"
+        },
+        {
+          "id": "multipolygon_london_parks"
+        },
+        {
+          "id": "linestring_putney_bridge"
+        },
+        {
+          "id": "envelope_brockwell_park"
+        }
+      ]
+    }
+  }
+]