Skip to content

Instantly share code, notes, and snippets.

@corrigancd
Last active April 16, 2020 10:07
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 corrigancd/1f892b1ff4a7ba154bc845eb707eb96d to your computer and use it in GitHub Desktop.
Save corrigancd/1f892b1ff4a7ba154bc845eb707eb96d to your computer and use it in GitHub Desktop.
Point 1:
I create an index with a geo_point field, add one document and filter based on a bool should filter, where each shape is part of the MultiPolygon that makes up the external bounds of the USA. The result is below and all is well.
PUT companywithpoint
{
"mappings": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
POST companywithpoint/_doc/insideus
{
"location": {
"lon": -100.0,
"lat": 40.0
}
}
The query below contains a new filter for each shape that makes up the external bounds of the USA. See here for query.
Result - all is well
{
"took" : 34,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 2.0,
"hits" : [
{
"_index" : "companywithpoint",
"_type" : "_doc",
"_id" : "insideus",
"_score" : 2.0,
"_source" : {
"location" : {
"lon" : -100.0,
"lat" : 40.0
}
}
}
]
}
}
Point 2 - I create an index with a shape type field and add two point documents to it. One is inside the country Ireland, while the other is inside the USA.
PUT companywithshape
{
"mappings": {
"properties": {
"location": {
"type": "shape"
}
}
}
}
POST companywithshape/_doc/insideireland
{
"location": {
"type": "point",
"coordinates": [-7.87, 53.0]
}
}
POST companywithshape/_doc/insideus
{
"location": {
"type": "point",
"coordinates": [-100.0, 40.0]
}
}
I create an index with a shape type field and add two documents. I had difficulty ingesting the MultiPolygon type that makes up the USA, but did so using the curl command below:
PUT .map__countries
{
"settings": {
"analysis": {
"analyzer": {
"spatial_path_analyzer": {
"tokenizer": "spatial_path_tokenizer"
}
},
"tokenizer": {
"spatial_path_tokenizer": {
"type": "path_hierarchy",
"delimiter": "/"
}
}
}
},
"mappings": {
"properties": {
"spatial_path": {
"type": "text",
"analyzer": "spatial_path_analyzer",
"fielddata": true,
"fields": {
"raw": {
"type": "keyword"
}
}
},
"geometry": {
"type": "shape"
}
}
}
}
POST .map__countries/_doc/ireland
{
"spatial_path": "landuse",
"geometry":{
"type":"MultiPolygon",
"coordinates":[ [[[-6.19788489,53.86756501],[-6.0329854,53.15316417],[-6.78885657,52.26011791],[-8.56161658,51.66930126],[-9.97708574,51.82045482],[-9.16628252,52.86462881],[-9.68852454,53.88136262],[-8.32798743,54.66451895],[-7.57216793,55.13162222],[-7.36603065,54.59584097],[-7.57216793,54.05995637],[-6.95373023,54.0737023],[-6.19788489,53.86756501]]]
]
}
}
Curl command:
curl -XPUT -H "Content-Type: application/json" --data "@usa.json" http://localhost:9200/.map__countries/_doc/usa
The contents of usa.json:
{
"spatial_path": "landuse",
"geometry":{
"type":"MultiPolygon",
"coordinates": [
[
[
[-122.84,49],[-122.97421,49.00253778],[-124.91024,49.98456],[-125.62461,50.41656],[-127.43561,50.83061],[-127.99276,51.71583],[-127.85032,52.32961],[-129.12979,52.75538],[-129.30523,53.56159],[-130.51497,54.28757],[-130.53610895,54.80275448],[-130.53611,54.80278],[-129.98,55.285],[-130.00778,55.91583],[-131.70781,56.55212],[-132.73042,57.69289],[-133.35556,58.41028],[-134.27111,58.86111],[-134.945,59.27056],[-135.47583,59.78778],[-136.47972,59.46389],[-137.4525,58.905],[-138.34089,59.56211],[-139.039,60],[-140.013,60.27682],[-140.99778,60.30639],[-140.9925,66.00003],[-140.986,69.712],[-140.98598761,69.7119984],[-139.12052,69.47102],[-137.54636,68.99002],[-136.50358,68.89804],[-135.62576,69.31512],[-134.41464,69.62743],[-132.92925,69.50534],[-131.43136,69.94451],[-129.79471,70.19369],[-129.10773,69.77927],[-128.36156,70.01286],[-128.13817,70.48384],[-127.44712,70.37721],[-125.75632,69.48058],[-124.42483,70.1584],[-124.28968,69.39969],[-123.06108,69.56372],[-122.6835,69.85553],[-121.47226,69.79778],[-119.94288,69.37786],[-117.60268,69.01128],[-116.22643,68.84151],[-115.2469,68.90591],[-113.89794,68.3989],[-115.30489,67.90261],[-113.49727,67.68815],[-110.798,67.80612],[-109.94619,67.98104],[-108.8802,67.38144],[-107.79239,67.88736],[-108.81299,68.31164],[-108.16721,68.65392],[-106.95,68.7],[-106.15,68.8],[-105.34282,68.56122],[-104.33791,68.018],[-103.22115,68.09775],[-101.45433,67.64689],[-99.90195,67.80566],[-98.4432,67.78165],[-98.5586,68.40394],[-97.66948,68.57864],[-96.11991,68.23939],[-96.12588,67.29338],[-95.48943,68.0907],[-94.685,68.06383],[-94.23282,69.06903],[-95.30408,69.68571],[-96.47131,70.08976],[-96.39115,71.19482],[-95.2088,71.92053],[-93.88997,71.76015],[-92.87818,71.31869],[-91.51964,70.19129],[-92.40692,69.69997],[-90.5471,69.49766],[-90.55151,68.47499],[-89.21515,69.25873],[-88.01966,68.61508],[-88.31749,67.87338],[-87.35017,67.19872],[-86.30607,67.92146],[-85.57664,68.78456],[-85.52197,69.88211],[-84.10081,69.80539],[-82.62258,69.65826],[-81.28043,69.16202],[-81.2202,68.66567],[-81.96436,68.13253],[-81.25928,67.59716],[-81.38653,67.11078],[-83.34456,66.41154],[-84.73542,66.2573],[-85.76943,66.55833],[-86.0676,66.05625],[-87.03143,65.21297],[-87.32324,64.77563],[-88.48296,64.09897],[-89.91444,64.03273],[-90.70398,63.61017],[-90.77004,62.96021],[-91.93342,62.83508],[-93.15698,62.02469],[-94.24153,60.89865],[-94.62931,60.11021],[-94.6846,58.94882],[-93.21502,58.78212],[-92.76462,57.84571],[-92.29703,57.08709],[-90.89769,57.28468],[-89.03953,56.85172],[-88.03978,56.47162],[-87.32421,55.99914],[-86.07121,55.72383],[-85.01181,55.3026],[-83.36055,55.24489],[-82.27285,55.14832],[-82.4362,54.28227],[-82.12502,53.27703],[-81.40075,52.15788],[-79.91289,51.20842],[-79.14301,51.53393],[-78.60191,52.56208],[-79.12421,54.14145],[-79.82958,54.66772],[-78.22874,55.13645],[-77.0956,55.83741],[-76.54137,56.53423],[-76.62319,57.20263],[-77.30226,58.05209],[-78.51688,58.80458],[-77.33676,59.85261],[-77.77272,60.75788],[-78.10687,62.31964],[-77.41067,62.55053],[-75.69621,62.2784],[-74.6682,62.18111],[-73.83988,62.4438],[-72.90853,62.10507],[-71.67708,61.52535],[-71.37369,61.13717],[-69.59042,61.06141],[-69.62033,60.22125],[-69.2879,58.95736],[-68.37455,58.80106],[-67.64976,58.21206],[-66.20178,58.76731],[-65.24517,59.87071],[-64.58352,60.33558],[-63.80475,59.4426],[-62.50236,58.16708],[-61.39655,56.96745],[-61.79866,56.33945],[-60.46853,55.77548],[-59.56962,55.20407],[-57.97508,54.94549],[-57.3332,54.6265],[-56.93689,53.78032],[-56.15811,53.64749],[-55.75632,53.27036],[-55.68338,52.14664],[-56.40916,51.7707],[-57.12691,51.41972],[-58.77482,51.0643],[-60.03309,50.24277],[-61.72366,50.08046],[-63.86251,50.29099],[-65.36331,50.2982],[-66.39905,50.22897],[-67.23631,49.51156],[-68.51114,49.06836],[-69.95362,47.74488],[-71.10458,46.82171],[-70.25522,46.98606],[-68.65,48.3],[-66.55243,49.1331],[-65.05626,49.23278],[-64.17099,48.74248],[-65.11545,48.07085],[-64.79854,46.99297],[-64.47219,46.23849],[-63.17329,45.73902],[-61.52072,45.88377],[-60.51815,47.00793],[-60.4486,46.28264],[-59.80287,45.9204],[-61.03988,45.26525],[-63.25471,44.67014],[-64.24656,44.26553],[-65.36406,43.54523],[-66.1234,43.61867],[-66.16173,44.46512],[-64.42549,45.29204],[-66.02605,45.25931],[-67.13741,45.13753],[-67.79134,45.70281],[-67.79046,47.06636],[-68.23444,47.35486],[-68.905,47.185],[-69.237216,47.447781],[-69.99997,46.69307],[-70.305,45.915],[-70.66,45.46],[-71.08482,45.30524],[-71.405,45.255],[-71.50506,45.0082],[-73.34783,45.00738],[-74.867,45.00048],[-75.31821,44.81645],[-76.375,44.09631],[-76.5,44.01845889],[-76.82003415,43.62878429],[-77.7378851,43.62905559],[-78.72027991,43.62508942],[-79.17167355,43.46633942],[-79.01,43.27],[-78.92,42.965],[-78.93936215,42.86361136],[-80.24744768,42.36619986],[-81.27774655,42.20902599],[-82.43927772,41.67510509],[-82.69008928,41.67510509],[-83.02981015,41.83279572],[-83.14199968,41.97568106],[-83.12,42.08],[-82.9,42.43],[-82.43,42.98],[-82.13764238,43.57108755],[-82.33776313,44.44],[-82.55092465,45.34751659],[-83.59285071,45.81689362],[-83.46955075,45.99468639],[-83.61613095,46.11692699],[-83.89076535,46.11692699],[-84.09185126,46.27541861],[-84.14211951,46.51222586],[-84.3367,46.40877],[-84.6049,46.4396],[-84.54374875,46.53868419],[-84.77923825,46.63710196],[-84.87607988,46.90008332],[-85.65236325,47.22021882],[-86.46199083,47.55333802],[-87.43979262,47.94],[-88.37811418,48.30291759],[-89.27291745,48.01980825],[-89.6,48.01],[-90.83,48.27],[-91.64,48.14],[-92.61,48.45],[-93.63087,48.60926],[-94.32914,48.67074],[-94.64,48.84],[-94.81758,49.38905],[-95.15609,49.38425],[-95.15906951,49],[-97.22872,49.0007],[-100.65,49],[-104.04826,48.99986],[-107.05,49],[-110.05,49],[-113,49],[-116.04818,49],[-117.03121,49],[-120,49],[-122.84,49]]],[[[-83.99367,62.4528],[-83.25048,62.91409],[-81.87699,62.90458],[-81.89825,62.7108],[-83.06857,62.15922],[-83.77462,62.18231],[-83.99367,62.4528]]],[[[-79.77583313,72.80290222],[-80.87609863,73.33318329],[-80.83388519,73.6931839],[-80.35305786,73.75971985],[-78.06443787,73.65193176],[-76.34,73.10268499],[-76.25140381,72.8263855],[-77.31443787,72.85554504],[-78.39167023,72.87665558],[-79.48625183,72.74220276],[-79.77583313,72.80290222]]],[[[-80.315395,62.085565],[-79.92939,62.3856],[-79.52002,62.36371],[-79.26582,62.158675],[-79.65752,61.63308],[-80.09956,61.7181],[-80.36215,62.01649],[-80.315395,62.085565]]],[[[-93.61275591,74.97999726],[-94.15690874,74.5923465],[-95.60868059,74.66686392],[-96.82093218,74.9276232],[-96.28858741,75.37782827],[-94.85081987,75.64721752],[-93.97774655,75.29648957],[-93.61275591,74.97999726]]],[[[-93.84000302,77.51999726],[-94.29560828,77.49134268],[-96.1696541,77.5551114],[-96.43630449,77.83462922],[-94.42257728,77.82000479],[-93.7206563,77.63433137],[-93.84000302,77.51999726]]],[[[-96.75439877,78.76581269],[-95.55927792,78.41831452],[-95.83029497,78.05694123],[-97.3098429,77.85059724],[-98.12428931,78.08285696],[-98.5528678,78.45810537],[-98.63198442,78.87193024],[-97.33723141,78.83198436],[-96.75439877,78.76581269]]],[[[-88.15035031,74.39230703],[-89.76472205,74.51555533],[-92.42244097,74.83775788],[-92.76828549,75.38681997],[-92.88990597,75.88265534],[-93.89382402,76.31924368],[-95.96245745,76.44138093],[-97.12137895,76.75107779],[-96.74512285,77.16138866],[-94.68408586,77.09787832],[-93.57392107,76.77629588],[-91.60502316,76.77851797],[-90.74184587,76.44959748],[-90.96966142,76.07401317],[-89.82223792,75.84777375],[-89.18708289,75.61016551],[-87.83827633,75.56618887],[-86.37919227,75.48242137],[-84.78962521,75.69920401],[-82.75344459,75.78431509],[-81.12853085,75.71398347],[-80.05751095,75.33684886],[-79.83393287,74.92312735],[-80.45777076,74.65730378],[-81.94884254,74.44245901],[-83.2288936,74.56402782],[-86.09745236,74.41003205],[-88.15035031,74.39230703]]],[[[-111.26444333,78.15295604],[-109.85445187,77.99632477],[-110.18693804,77.69701488],[-112.05119117,77.40922883],[-113.53427894,77.73220653],[-112.72458676,78.05105012],[-111.26444333,78.15295604]]],[[[-110.96366065,78.80444082],[-109.66314572,78.60197256],[-110.88131426,78.40691987],[-112.54209144,78.40790172],[-112.52589088,78.55055451],[-111.50001034,78.8499936],[-110.96366065,78.80444082]]],[[[-55.60021827,51.31707469],[-56.13403581,50.68700979],[-56.79588172,49.81230866],[-56.14310503,50.1501175],[-55.47149228,49.93581533],[-55.82240109,49.58712861],[-54.93514258,49.31301097],[-54.4737754,49.55669119],[-53.47654945,49.2491389],[-53.78601376,48.5167805],[-53.086134,48.68780366],[-52.95864824,48.15716421],[-52.64809872,47.53554841],[-53.06915829,46.65549877],[-53.52145626,46.61829173],[-54.17893551,46.80706574],[-53.96186866,47.62520702],[-54.24048214,47.75227936],[-55.40077308,46.8849938],[-55.99748084,46.91972036],[-55.29121904,47.38956249],[-56.25079871,47.63254507],[-57.32522925,47.57280712],[-59.26601518,47.60334789],[-59.41949419,47.89945384],[-58.79658647,48.25152538],[-59.23162452,48.52318838],[-58.39180498,49.12558055],[-57.35868974,50.71827403],[-56.73865007,51.28743826],[-55.87097694,51.63209422],[-55.40697425,51.58827261],[-55.60021827,51.31707469]]],[[[-83.88262631,65.10961782],[-82.78757687,64.76669302],[-81.64201372,64.45513581],[-81.55344031,63.97960928],[-80.81736121,64.05748566],[-80.1034513,63.72598135],[-80.99101986,63.41124604],[-82.54717811,63.65172232],[-83.10879757,64.10187572],[-84.10041663,63.56971182],[-85.52340471,63.05237906],[-85.86676876,63.63725292],[-87.2219832,63.5412381],[-86.35275977,64.03583324],[-86.22488644,64.82291698],[-85.88384783,65.73877839],[-85.16130795,65.65728465],[-84.97576372,65.21751822],[-84.46401201,65.37177237],[-83.88262631,65.10961782]]],[[[-78.7706386,72.35217316],[-77.82462399,72.7496166],[-75.60584469,72.24367849],[-74.2286161,71.76714427],[-74.09914079,71.33084016],[-72.24222571,71.55692455],[-71.20001543,70.92001252],[-68.78605425,70.52502371],[-67.91497047,70.12194754],[-66.96903337,69.18608735],[-68.80512285,68.72019847],[-66.4498661,68.0671634],[-64.86231442,67.84753856],[-63.42493445,66.92847321],[-61.85198137,66.86212067],[-62.16317685,66.16025137],[-63.91844438,64.99866852],[-65.14886024,65.42603262],[-66.72121904,66.38804108],[-68.01501604,66.26272574],[-68.1412874,65.68978913],[-67.08964617,65.10845511],[-65.73208045,64.64840567],[-65.32016761,64.38273713],[-64.6694063,63.39292674],[-65.01380388,62.67418509],[-66.27504473,62.94509878],[-68.7831862,63.74567007],[-67.36968075,62.88396556],[-66.32829729,62.28007477],[-66.1655682,61.93089712],[-68.8773665,62.33014924],[-71.02343706,62.91070812],[-72.23537859,63.39783601],[-71.88627845,63.67998933],[-73.37830624,64.19396312],[-74.83441891,64.67907563],[-74.81850257,64.38909333],[-77.70997982,64.22954234],[-78.55594886,64.5729064],[-77.89728105,65.30919221],[-76.0182743,65.3269689],[-73.95979529,65.45476472],[-74.29388343,65.81177135],[-73.94491248,66.31057811],[-72.65116716,67.28457551],[-72.92605994,67.72692577],[-73.3116178,68.06943716],[-74.84330726,68.55462718],[-76.86910092,68.89473562],[-76.22864905,69.14776927],[-77.28736996,69.76954011],[-78.168634,69.82648754],[-78.95724219,70.16688019],[-79.492455,69.87180777],[-81.30547095,69.74318513],[-84.94470618,69.96663402],[-87.06000342,70.26000113],[-88.68171322,70.41074128],[-89.51341956,70.76203767],[-88.46772112,71.21818553],[-89.88815121,71.22255219],[-90.20516029,72.23507437],[-89.43657671,73.12946422],[-88.40824154,73.5378889],[-85.82615109,73.80381582],[-86.56217851,73.15744701],[-85.7743713,72.53412588],[-84.85011247,73.34027823],[-82.31559018,73.75095083],[-80.60008765,72.71654369],[-80.74894162,72.06190664],[-78.7706386,72.35217316]]],[[[-94.5036576,74.13490672],[-92.42001217,74.10002513],[-90.50979285,73.85673249],[-92.00396522,72.96624421],[-93.19629554,72.7719925],[-94.2690466,72.02459626],[-95.40985552,72.06188081],[-96.03374508,72.9402768],[-96.01826799,73.43742992],[-95.49579342,73.8624169],[-94.5036576,74.13490672]]],[[[-122.85492449,76.11654287],[-122.85492529,76.11654287],[-121.15753536,76.86450755],[-119.10393897,77.51221996],[-117.57013078,77.498319],[-116.1985866,77.64528677],[-116.33581336,76.87696158],[-117.10605058,76.53003185],[-118.04041216,76.48117178],[-119.89931759,76.05321341],[-121.49999508,75.90001862],[-122.85492449,76.11654287]]],[[[-132.71000788,54.04000932],[-131.74998958,54.12000438],[-132.04948035,52.98462149],[-131.17904252,52.18043285],[-131.57782955,52.18237071],[-132.18042843,52.63970714],[-132.54999243,53.10001496],[-133.05461118,53.41146882],[-133.23966448,53.85108023],[-133.18000404,54.16997549],[-132.71000788,54.04000932]]],[[[-105.49228919,79.30159394],[-103.5292824,79.16534903],[-100.82515805,78.80046174],[-100.06019182,78.32475434],[-99.67093909,77.90754466],[-101.30394019,78.01898489],[-102.94980872,78.34322866],[-105.17613278,78.38033234],[-104.21042945,78.67742015],[-105.41958045,78.91833568],[-105.49228919,79.30159394]]],[[[-123.51000159,48.51001089],[-124.01289079,48.37084626],[-125.65501278,48.82500458],[-125.95499447,49.17999584],[-126.85000444,49.53000031],[-127.02999345,49.81499584],[-128.0593363,49.99495901],[-128.44458411,50.53913768],[-128.35841366,50.7706481],[-127.3085811,50.55257355],[-126.69500098,50.40090323],[-125.75500667,50.29501822],[-125.41500159,49.95000052],[-124.92076819,49.47527497],[-123.92250871,49.06248363],[-123.51000159,48.51001089]]],[[[-121.53788,74.44893],[-120.10978,74.24135],[-117.55564,74.18577],[-116.58442,73.89607],[-115.51081,73.47519],[-116.76794,73.22292],[-119.22,72.52],[-120.46,71.82],[-120.46,71.38360179],[-123.09219,70.90164],[-123.62,71.34],[-125.92894874,71.86868846],[-125.5,72.29226081],[-124.80729,73.02256],[-123.94,73.68],[-124.91775,74.29275],[-121.53788,74.44893]]],[[[-107.81943,75.84552],[-106.92893,76.01282],[-105.881,75.9694],[-105.70498,75.47951],[-106.31347,75.00527],[-109.7,74.85],[-112.22307,74.41696],[-113.74381,74.39427],[-113.87135,74.72029],[-111.79421,75.1625],[-116.31221,75.04343],[-117.7104,75.2222],[-116.34602,76.19903],[-115.40487,76.47887],[-112.59056,76.14134],[-110.81422,75.54919],[-109.0671,75.47321],[-110.49726,76.42982],[-109.5811,76.79417],[-108.54859,76.67832],[-108.21141,76.20168],[-107.81943,75.84552]]],[[[-106.52259,73.07601],[-105.40246,72.67259],[-104.77484,71.6984],[-104.46476,70.99297],[-102.78537,70.49776],[-100.98078,70.02432],[-101.08929,69.58447],[-102.73116,69.50402],[-102.09329,69.11962],[-102.43024,68.75282],[-104.24,68.91],[-105.96,69.18],[-107.12254,69.11922],[-109,68.78],[-111.53414888,68.63005916],[-113.3132,68.53554],[-113.85496,69.00744],[-115.22,69.28],[-116.10794,69.16821],[-117.34,69.96],[-116.67473,70.06655],[-115.13112,70.2373],[-113.72141,70.19237],[-112.4161,70.36638],[-114.35,70.6],[-116.48684,70.52045],[-117.9048,70.54056],[-118.43238,70.9092],[-116.11311,71.30918],[-117.65568,71.2952],[-119.40199,71.55859],[-118.56267,72.30785],[-117.86642,72.70594],[-115.18909,73.31459],[-114.16717,73.12145],[-114.66634,72.65277],[-112.44102,72.9554],[-111.05039,72.4504],[-109.92035,72.96113],[-109.00654,72.63335],[-108.18835,71.65089],[-107.68599,72.06548],[-108.39639,73.08953],[-107.51645,73.23598],[-106.52259,73.07601]]],[[[-100.43836,72.70588],[-101.54,73.36],[-100.35642,73.84389],[-99.16387,73.63339],[-97.38,73.76],[-97.12,73.47],[-98.05359,72.99052],[-96.54,72.56],[-96.72,71.66],[-98.35966,71.27285],[-99.32286,71.35639],[-100.01482,71.73827],[-102.5,72.51],[-102.48,72.83],[-100.43836,72.70588]]],[[[-106.6,73.6],[-105.26,73.64],[-104.5,73.42],[-105.38,72.76],[-106.94,73.46],[-106.6,73.6]]],[[[-98.5,76.72],[-97.735585,76.25656],[-97.704415,75.74344],[-98.16,75],[-99.80874,74.89744],[-100.88366,75.05736],[-100.86292,75.64075],[-102.50209,75.5638],[-102.56552,76.3366],[-101.48973,76.30537],[-99.98349,76.64634],[-98.57699,76.58859],[-98.5,76.72]]],[[[-96.01644,80.60233],[-95.32345,80.90729],[-94.29843,80.97727],[-94.73542,81.20646],[-92.40984,81.25739],[-91.13289,80.72345],[-89.45,80.50932203],[-87.81,80.32],[-87.02,79.66],[-85.81435,79.3369],[-87.18756,79.0393],[-89.03535,78.28723],[-90.80436,78.21533],[-92.87669,78.34333],[-93.95116,78.75099],[-93.93574,79.11373],[-93.14524,79.3801],[-94.974,79.37248],[-96.07614,79.70502],[-96.70972,80.15777],[-96.01644,80.60233]]],[[[-91.58702,81.89429],[-90.1,82.085],[-88.93227,82.11751],[-86.97024,82.27961],[-85.5,82.65227346],[-84.260005,82.6],[-83.18,82.32],[-82.42,82.86],[-81.1,83.02],[-79.30664,83.13056],[-76.25,83.17205882],[-75.71878,83.06404],[-72.83153,83.23324],[-70.665765,83.16978076],[-68.5,83.10632152],[-65.82735,83.02801],[-63.68,82.9],[-61.85,82.6286],[-61.89388,82.36165],[-64.334,81.92775],[-66.75342,81.72527],[-67.65755,81.50141],[-65.48031,81.50657],[-67.84,80.9],[-69.4697,80.61683],[-71.18,79.8],[-73.2428,79.63415],[-73.88,79.4301622],[-76.90773,79.32309],[-75.52924,79.19766],[-76.22046,79.01907],[-75.39345,78.52581],[-76.34354,78.18296],[-77.88851,77.89991],[-78.36269,77.50859],[-79.75951,77.20968],[-79.61965,76.98336],[-77.91089,77.022045],[-77.88911,76.777955],[-80.56125,76.17812],[-83.17439,76.45403],[-86.11184,76.29901],[-87.6,76.42],[-89.49068,76.47239],[-89.6161,76.95213],[-87.76739,77.17833],[-88.26,77.9],[-87.65,77.97022222],[-84.97634,77.53873],[-86.34,78.18],[-87.96192,78.37181],[-87.15198,78.75867],[-85.37868,78.9969],[-85.09495,79.34543],[-86.50734,79.73624],[-86.93179,80.25145],[-84.19844,80.20836],[-83.40869565,80.1],[-81.84823,80.46442],[-84.1,80.58],[-87.59895,80.51627],[-89.36663,80.85569],[-90.2,81.26],[-91.36786,81.5531],[-91.58702,81.89429]]],[[[-75.21597,67.44425],[-75.86588,67.14886],[-76.98687,67.09873],[-77.2364,67.58809],[-76.81166,68.14856],[-75.89521,68.28721],[-75.1145,68.01036],[-75.10333,67.58202],[-75.21597,67.44425]]],[[[-96.2574012,69.49003036],[-95.6476812,69.10769036],[-96.2695212,68.75704036],[-97.6174012,69.06003036],[-98.4318012,68.95070036],[-99.7974012,69.40003036],[-98.9174012,69.71003036],[-98.2182612,70.14354036],[-97.1574012,69.86003036],[-96.5574012,69.68003036],[-96.2574012,69.49003036]]],[[[-64.51912,49.87304],[-64.17322,49.95718],[-62.85829,49.70641],[-61.835585,49.28855],[-61.806305,49.10506],[-62.29318,49.08717],[-63.58926,49.40069],[-64.51912,49.87304]]],[[[-64.01486,47.03601],[-63.6645,46.55001],[-62.9393,46.41587],[-62.01208,46.44314],[-62.50391,46.03339],[-62.87433,45.96818],[-64.1428,46.39265],[-64.39261,46.72747],[-64.01486,47.03601]]]
]
}
}
When I run the query below, I get the expected response (also below), i.e. the document that has a point in Ireland is returned:
Query
GET companywithshape/_search
{
"query": {
"bool": {
"must": [
{
"match_all": {}
},
{
"bool": {
"should": [
{
"shape": {
"location": {
"indexed_shape": {
"id": "ireland",
"index": ".map__countries",
"path": "geometry"
},
"relation": "intersects"
}
}
}
]
}
}
],
"must_not": []
}
}
}
Response
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "companywithshape",
"_type" : "_doc",
"_id" : "insideireland",
"_score" : 1.0,
"_source" : {
"location" : {
"type" : "point",
"coordinates" : [
-7.87,
53.0
]
}
}
}
]
}
}
When I run the query below (which is the same as the one for Ireland above except the id is changed from ireland to usa), I get an empty response:
Query
GET companywithshape/_search
{
"query": {
"bool": {
"must": [
{
"match_all": {}
},
{
"bool": {
"should": [
{
"shape": {
"location": {
"indexed_shape": {
"id": "usa",
"index": ".map__countries",
"path": "geometry"
},
"relation": "intersects"
}
}
}
]
}
}
],
"must_not": []
}
}
}
Response
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
}
}
Full Query with each polygon of USA multipolygon being a separate shape
GET companywithpoint/_search
{
"query": {
"bool": {
"must": [
{
"match_all": {}
},
{
"bool": {
"should": [
{
"geo_polygon": {
"location": {
"points": [
[
-122.84,
49
],
[
-120,
49
],
[
-117.03121,
49
],
[
-116.04818,
49
],
[
-113,
49
],
[
-110.05,
49
],
[
-107.05,
49
],
[
-104.04826,
48.99986
],
[
-100.65,
49
],
[
-97.22872,
49.0007
],
[
-95.15907,
49
],
[
-95.15609,
49.38425
],
[
-94.81758,
49.38905
],
[
-94.64,
48.84
],
[
-94.32914,
48.67074
],
[
-93.63087,
48.60926
],
[
-92.61,
48.45
],
[
-91.64,
48.14
],
[
-90.83,
48.27
],
[
-89.6,
48.01
],
[
-89.272917,
48.019808
],
[
-88.378114,
48.302918
],
[
-87.439793,
47.94
],
[
-86.461991,
47.553338
],
[
-85.652363,
47.220219
],
[
-84.87608,
46.900083
],
[
-84.779238,
46.637102
],
[
-84.543749,
46.538684
],
[
-84.6049,
46.4396
],
[
-84.3367,
46.40877
],
[
-84.14212,
46.512226
],
[
-84.091851,
46.275419
],
[
-83.890765,
46.116927
],
[
-83.616131,
46.116927
],
[
-83.469551,
45.994686
],
[
-83.592851,
45.816894
],
[
-82.550925,
45.347517
],
[
-82.337763,
44.44
],
[
-82.137642,
43.571088
],
[
-82.43,
42.98
],
[
-82.9,
42.43
],
[
-83.12,
42.08
],
[
-83.142,
41.975681
],
[
-83.02981,
41.832796
],
[
-82.690089,
41.675105
],
[
-82.439278,
41.675105
],
[
-81.277747,
42.209026
],
[
-80.247448,
42.3662
],
[
-78.939362,
42.863611
],
[
-78.92,
42.965
],
[
-79.01,
43.27
],
[
-79.171674,
43.466339
],
[
-78.72028,
43.625089
],
[
-77.737885,
43.629056
],
[
-76.820034,
43.628784
],
[
-76.5,
44.018459
],
[
-76.375,
44.09631
],
[
-75.31821,
44.81645
],
[
-74.867,
45.00048
],
[
-73.34783,
45.00738
],
[
-71.50506,
45.0082
],
[
-71.405,
45.255
],
[
-71.08482,
45.30524
],
[
-70.66,
45.46
],
[
-70.305,
45.915
],
[
-69.99997,
46.69307
],
[
-69.237216,
47.447781
],
[
-68.905,
47.185
],
[
-68.23444,
47.35486
],
[
-67.79046,
47.06636
],
[
-67.79134,
45.70281
],
[
-67.13741,
45.13753
],
[
-66.96466,
44.8097
],
[
-68.03252,
44.3252
],
[
-69.06,
43.98
],
[
-70.11617,
43.68405
],
[
-70.645476,
43.090238
],
[
-70.81489,
42.8653
],
[
-70.825,
42.335
],
[
-70.495,
41.805
],
[
-70.08,
41.78
],
[
-70.185,
42.145
],
[
-69.88497,
41.92283
],
[
-69.96503,
41.63717
],
[
-70.64,
41.475
],
[
-71.12039,
41.49445
],
[
-71.86,
41.32
],
[
-72.295,
41.27
],
[
-72.87643,
41.22065
],
[
-73.71,
40.931102
],
[
-72.24126,
41.11948
],
[
-71.945,
40.93
],
[
-73.345,
40.63
],
[
-73.982,
40.628
],
[
-73.952325,
40.75075
],
[
-74.25671,
40.47351
],
[
-73.96244,
40.42763
],
[
-74.17838,
39.70926
],
[
-74.90604,
38.93954
],
[
-74.98041,
39.1964
],
[
-75.20002,
39.24845
],
[
-75.52805,
39.4985
],
[
-75.32,
38.96
],
[
-75.071835,
38.782032
],
[
-75.05673,
38.40412
],
[
-75.37747,
38.01551
],
[
-75.94023,
37.21689
],
[
-76.03127,
37.2566
],
[
-75.72205,
37.93705
],
[
-76.23287,
38.319215
],
[
-76.35,
39.15
],
[
-76.542725,
38.717615
],
[
-76.32933,
38.08326
],
[
-76.989998,
38.239992
],
[
-76.30162,
37.917945
],
[
-76.25874,
36.9664
],
[
-75.9718,
36.89726
],
[
-75.86804,
36.55125
],
[
-75.72749,
35.55074
],
[
-76.36318,
34.80854
],
[
-77.397635,
34.51201
],
[
-78.05496,
33.92547
],
[
-78.55435,
33.86133
],
[
-79.06067,
33.49395
],
[
-79.20357,
33.15839
],
[
-80.301325,
32.509355
],
[
-80.86498,
32.0333
],
[
-81.33629,
31.44049
],
[
-81.49042,
30.72999
],
[
-81.31371,
30.03552
],
[
-80.98,
29.18
],
[
-80.535585,
28.47213
],
[
-80.53,
28.04
],
[
-80.056539,
26.88
],
[
-80.088015,
26.205765
],
[
-80.13156,
25.816775
],
[
-80.38103,
25.20616
],
[
-80.68,
25.08
],
[
-81.17213,
25.20126
],
[
-81.33,
25.64
],
[
-81.71,
25.87
],
[
-82.24,
26.73
],
[
-82.70515,
27.49504
],
[
-82.85526,
27.88624
],
[
-82.65,
28.55
],
[
-82.93,
29.1
],
[
-83.70959,
29.93656
],
[
-84.1,
30.09
],
[
-85.10882,
29.63615
],
[
-85.28784,
29.68612
],
[
-85.7731,
30.15261
],
[
-86.4,
30.4
],
[
-87.53036,
30.27433
],
[
-88.41782,
30.3849
],
[
-89.18049,
30.31598
],
[
-89.593831,
30.159994
],
[
-89.413735,
29.89419
],
[
-89.43,
29.48864
],
[
-89.21767,
29.29108
],
[
-89.40823,
29.15961
],
[
-89.77928,
29.30714
],
[
-90.15463,
29.11743
],
[
-90.880225,
29.148535
],
[
-91.626785,
29.677
],
[
-92.49906,
29.5523
],
[
-93.22637,
29.78375
],
[
-93.84842,
29.71363
],
[
-94.69,
29.48
],
[
-95.60026,
28.73863
],
[
-96.59404,
28.30748
],
[
-97.14,
27.83
],
[
-97.37,
27.38
],
[
-97.38,
26.69
],
[
-97.33,
26.21
],
[
-97.14,
25.87
],
[
-97.53,
25.84
],
[
-98.24,
26.06
],
[
-99.02,
26.37
],
[
-99.3,
26.84
],
[
-99.52,
27.54
],
[
-100.11,
28.11
],
[
-100.45584,
28.69612
],
[
-100.9576,
29.38071
],
[
-101.6624,
29.7793
],
[
-102.48,
29.76
],
[
-103.11,
28.97
],
[
-103.94,
29.27
],
[
-104.45697,
29.57196
],
[
-104.70575,
30.12173
],
[
-105.03737,
30.64402
],
[
-105.63159,
31.08383
],
[
-106.1429,
31.39995
],
[
-106.50759,
31.75452
],
[
-108.24,
31.754854
],
[
-108.24194,
31.34222
],
[
-109.035,
31.34194
],
[
-111.02361,
31.33472
],
[
-113.30498,
32.03914
],
[
-114.815,
32.52528
],
[
-114.72139,
32.72083
],
[
-115.99135,
32.61239
],
[
-117.12776,
32.53534
],
[
-117.295938,
33.046225
],
[
-117.944,
33.621236
],
[
-118.410602,
33.740909
],
[
-118.519895,
34.027782
],
[
-119.081,
34.078
],
[
-119.438841,
34.348477
],
[
-120.36778,
34.44711
],
[
-120.62286,
34.60855
],
[
-120.74433,
35.15686
],
[
-121.71457,
36.16153
],
[
-122.54747,
37.55176
],
[
-122.51201,
37.78339
],
[
-122.95319,
38.11371
],
[
-123.7272,
38.95166
],
[
-123.86517,
39.76699
],
[
-124.39807,
40.3132
],
[
-124.17886,
41.14202
],
[
-124.2137,
41.99964
],
[
-124.53284,
42.76599
],
[
-124.14214,
43.70838
],
[
-124.020535,
44.615895
],
[
-123.89893,
45.52341
],
[
-124.079635,
46.86475
],
[
-124.39567,
47.72017
],
[
-124.68721,
48.184433
],
[
-124.566101,
48.379715
],
[
-123.12,
48.04
],
[
-122.58736,
47.096
],
[
-122.34,
47.36
],
[
-122.5,
48.18
],
[
-122.84,
49
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-155.40214,
20.07975
],
[
-155.22452,
19.99302
],
[
-155.06226,
19.8591
],
[
-154.80741,
19.50871
],
[
-154.83147,
19.45328
],
[
-155.22217,
19.23972
],
[
-155.54211,
19.08348
],
[
-155.68817,
18.91619
],
[
-155.93665,
19.05939
],
[
-155.90806,
19.33888
],
[
-156.07347,
19.70294
],
[
-156.02368,
19.81422
],
[
-155.85008,
19.97729
],
[
-155.91907,
20.17395
],
[
-155.86108,
20.26721
],
[
-155.78505,
20.2487
],
[
-155.40214,
20.07975
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-155.99566,
20.76404
],
[
-156.07926,
20.64397
],
[
-156.41445,
20.57241
],
[
-156.58673,
20.783
],
[
-156.70167,
20.8643
],
[
-156.71055,
20.92676
],
[
-156.61258,
21.01249
],
[
-156.25711,
20.91745
],
[
-155.99566,
20.76404
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-156.75824,
21.17684
],
[
-156.78933,
21.06873
],
[
-157.32521,
21.09777
],
[
-157.25027,
21.21958
],
[
-156.75824,
21.17684
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-158.0252,
21.71696
],
[
-157.94161,
21.65272
],
[
-157.65283,
21.32217
],
[
-157.70703,
21.26442
],
[
-157.7786,
21.27729
],
[
-158.12667,
21.31244
],
[
-158.2538,
21.53919
],
[
-158.29265,
21.57912
],
[
-158.0252,
21.71696
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-159.36569,
22.21494
],
[
-159.34512,
21.982
],
[
-159.46372,
21.88299
],
[
-159.80051,
22.06533
],
[
-159.74877,
22.1382
],
[
-159.5962,
22.23618
],
[
-159.36569,
22.21494
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-166.467792,
60.38417
],
[
-165.67443,
60.293607
],
[
-165.579164,
59.909987
],
[
-166.19277,
59.754441
],
[
-166.848337,
59.941406
],
[
-167.455277,
60.213069
],
[
-166.467792,
60.38417
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-153.228729,
57.968968
],
[
-152.564791,
57.901427
],
[
-152.141147,
57.591059
],
[
-153.006314,
57.115842
],
[
-154.00509,
56.734677
],
[
-154.516403,
56.992749
],
[
-154.670993,
57.461196
],
[
-153.76278,
57.816575
],
[
-153.228729,
57.968968
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-140.985988,
69.711998
],
[
-140.986,
69.712
],
[
-140.9925,
66.00003
],
[
-140.99778,
60.30639
],
[
-140.013,
60.27682
],
[
-139.039,
60
],
[
-138.34089,
59.56211
],
[
-137.4525,
58.905
],
[
-136.47972,
59.46389
],
[
-135.47583,
59.78778
],
[
-134.945,
59.27056
],
[
-134.27111,
58.86111
],
[
-133.35556,
58.41028
],
[
-132.73042,
57.69289
],
[
-131.70781,
56.55212
],
[
-130.00778,
55.91583
],
[
-129.98,
55.285
],
[
-130.53611,
54.80278
],
[
-130.536109,
54.802754
],
[
-130.53611,
54.802753
],
[
-131.085818,
55.178906
],
[
-131.967211,
55.497776
],
[
-132.250011,
56.369996
],
[
-133.539181,
57.178887
],
[
-134.078063,
58.123068
],
[
-135.038211,
58.187715
],
[
-136.628062,
58.212209
],
[
-137.800006,
58.499995
],
[
-139.867787,
59.537762
],
[
-140.825274,
59.727517
],
[
-142.574444,
60.084447
],
[
-143.958881,
59.99918
],
[
-145.925557,
60.45861
],
[
-147.114374,
60.884656
],
[
-148.224306,
60.672989
],
[
-148.018066,
59.978329
],
[
-148.570823,
59.914173
],
[
-149.727858,
59.705658
],
[
-150.608243,
59.368211
],
[
-151.716393,
59.155821
],
[
-151.859433,
59.744984
],
[
-151.409719,
60.725803
],
[
-150.346941,
61.033588
],
[
-150.621111,
61.284425
],
[
-151.895839,
60.727198
],
[
-152.57833,
60.061657
],
[
-154.019172,
59.350279
],
[
-153.287511,
58.864728
],
[
-154.232492,
58.146374
],
[
-155.307491,
57.727795
],
[
-156.308335,
57.422774
],
[
-156.556097,
56.979985
],
[
-158.117217,
56.463608
],
[
-158.433321,
55.994154
],
[
-159.603327,
55.566686
],
[
-160.28972,
55.643581
],
[
-161.223048,
55.364735
],
[
-162.237766,
55.024187
],
[
-163.069447,
54.689737
],
[
-164.785569,
54.404173
],
[
-164.942226,
54.572225
],
[
-163.84834,
55.039431
],
[
-162.870001,
55.348043
],
[
-161.804175,
55.894986
],
[
-160.563605,
56.008055
],
[
-160.07056,
56.418055
],
[
-158.684443,
57.016675
],
[
-158.461097,
57.216921
],
[
-157.72277,
57.570001
],
[
-157.550274,
58.328326
],
[
-157.041675,
58.918885
],
[
-158.194731,
58.615802
],
[
-158.517218,
58.787781
],
[
-159.058606,
58.424186
],
[
-159.711667,
58.93139
],
[
-159.981289,
58.572549
],
[
-160.355271,
59.071123
],
[
-161.355003,
58.670838
],
[
-161.968894,
58.671665
],
[
-162.054987,
59.266925
],
[
-161.874171,
59.633621
],
[
-162.518059,
59.989724
],
[
-163.818341,
59.798056
],
[
-164.662218,
60.267484
],
[
-165.346388,
60.507496
],
[
-165.350832,
61.073895
],
[
-166.121379,
61.500019
],
[
-165.734452,
62.074997
],
[
-164.919179,
62.633076
],
[
-164.562508,
63.146378
],
[
-163.753332,
63.219449
],
[
-163.067224,
63.059459
],
[
-162.260555,
63.541936
],
[
-161.53445,
63.455817
],
[
-160.772507,
63.766108
],
[
-160.958335,
64.222799
],
[
-161.518068,
64.402788
],
[
-160.777778,
64.788604
],
[
-161.391926,
64.777235
],
[
-162.45305,
64.559445
],
[
-162.757786,
64.338605
],
[
-163.546394,
64.55916
],
[
-164.96083,
64.446945
],
[
-166.425288,
64.686672
],
[
-166.845004,
65.088896
],
[
-168.11056,
65.669997
],
[
-166.705271,
66.088318
],
[
-164.47471,
66.57666
],
[
-163.652512,
66.57666
],
[
-163.788602,
66.077207
],
[
-161.677774,
66.11612
],
[
-162.489715,
66.735565
],
[
-163.719717,
67.116395
],
[
-164.430991,
67.616338
],
[
-165.390287,
68.042772
],
[
-166.764441,
68.358877
],
[
-166.204707,
68.883031
],
[
-164.430811,
68.915535
],
[
-163.168614,
69.371115
],
[
-162.930566,
69.858062
],
[
-161.908897,
70.33333
],
[
-160.934797,
70.44769
],
[
-159.039176,
70.891642
],
[
-158.119723,
70.824721
],
[
-156.580825,
71.357764
],
[
-155.06779,
71.147776
],
[
-154.344165,
70.696409
],
[
-153.900006,
70.889989
],
[
-152.210006,
70.829992
],
[
-152.270002,
70.600006
],
[
-150.739992,
70.430017
],
[
-149.720003,
70.53001
],
[
-147.613362,
70.214035
],
[
-145.68999,
70.12001
],
[
-144.920011,
69.989992
],
[
-143.589446,
70.152514
],
[
-142.07251,
69.851938
],
[
-140.985988,
69.711998
],
[
-140.985988,
69.711998
]
]
}
}
},
{
"geo_polygon": {
"location": {
"points": [
[
-171.731657,
63.782515
],
[
-171.114434,
63.592191
],
[
-170.491112,
63.694975
],
[
-169.682505,
63.431116
],
[
-168.689439,
63.297506
],
[
-168.771941,
63.188598
],
[
-169.52944,
62.976931
],
[
-170.290556,
63.194438
],
[
-170.671386,
63.375822
],
[
-171.553063,
63.317789
],
[
-171.791111,
63.405846
],
[
-171.731657,
63.782515
]
]
}
}
}
]
}
}
],
"must_not": []
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment