Skip to content

Instantly share code, notes, and snippets.

@markharwood
Created October 22, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markharwood/c90f7abe1daa3640128b to your computer and use it in GitHub Desktop.
Save markharwood/c90f7abe1daa3640128b to your computer and use it in GitHub Desktop.
Shape intersects example
DELETE test
PUT test/
{
"mappings": {
"doc": {
"properties": {
"location": { "type": "geo_shape" }
}
}
}
}
POST test/doc
{
"location":{
"type" : "polygon",
"coordinates" :[ [
[
0.3515625,
57.89149735271031
],
[
0.3515625,
62.91523303947614
],
[
7.734374999999999,
62.91523303947614
],
[
7.734374999999999,
57.89149735271031
],
[
0.3515625,
57.89149735271031
]
] ]
}
}
GET test/doc/_search
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"coordinates": [
[
[
-8.7890625,
50.28933925329178
],
[
-8.7890625,
58.26328705248601
],
[
2.109375,
58.26328705248601
],
[
2.109375,
50.28933925329178
],
[
-8.7890625,
50.28933925329178
]
]
],
"type": "polygon"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
GET test/doc/_search
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"coordinates": [
[
[
-12.480468749999998,
44.08758502824518
],
[
-12.480468749999998,
49.38237278700955
],
[
-5.80078125,
49.38237278700955
],
[
-5.80078125,
44.08758502824518
],
[
-12.480468749999998,
44.08758502824518
]
]
],
"type": "polygon"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
GET test/doc/_search
{
"query": {
"filtered": {
"filter": {
"geo_shape": {
"location": {
"relation": "intersects",
"shape": {
"coordinates":[
[
[
4.39453125,
51.781435604431195
],
[
1.142578125,
48.04870994288686
],
[
1.142578125,
44.59046718130883
],
[
12.392578125,
44.84029065139799
],
[
11.513671874999998,
52.16045455774706
],
[
4.39453125,
51.781435604431195
]
]
],
"type": "polygon"
}
}
}
},
"query": {
"match_all": {}
}
}
}
}
@markharwood
Copy link
Author

Indexed doc is the black polygon.
Red polygons do not match the "intersects" query. Green polygon does.

geojson io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment