Re: Incorrect results from geo_shape filter

2015-02-19 Thread Alexei Peters
FYI, you can also try a search using these coordinates (which are clearly 
incorrect) in your filter, and it still returns a result.

 "coordinates": [ -119, 35 ]



On Thursday, February 19, 2015 at 3:04:29 PM UTC-8, Alexei Peters wrote:
>
> Hey Everyone,
>
> I have a nested document that includes a spatial component that I'm using 
> in a spatial query via the geo_shape filter.
> I've noticed that the filter consistently returns a result that includes a 
> geometry that clearly falls outside the spatial filter.
> I've tested the spatial intersection in PostGIS and that correctly returns 
> back no result from the same query.
>
> Can anyone else verify this?  We have lots of other MultiPolygon data that 
> seems to work just fine.
>
> I'm using the REST api against ES v1.4.1
>
> *Here's the document I'm testing against:*
>
> {"dates": [],
> "geometries": [{
>   "value": {
> "type": "MultiPolygon",
> "coordinates": [
>   [
> [
>   [-118.32608,
>   34.07035],
>   [-118.32657,
>   34.07035],
>   [-118.32657,
>   34.07054],
>   [-118.32608,
>   34.07054],
>   [-118.32608,
>   34.07035]
> ]
>   ],
>   [
> [
>   [-118.32608,
>   34.07021],
>   [-118.32608,
>   34.07004],
>   [-118.32657,
>   34.07004],
>   [-118.32657,
>   34.07021],
>   [-118.32608,
>   34.07021]
> ]
>   ]
> ]
>   },
>   "label": "MULTIPOLYGON (((-118.32608 34.07035,-118.32657 
> 34.07035,-118.32657 34.07054,-118.32608 34.07054,-118.32608 
> 34.07035)),((-118.32608 34.07021,-118.32608 34.07004,-118.32657 
> 34.07004,-118.32657 34.07021,-118.32608 34.07021)))",
>   "child_entities": [],
>   "entitytypeid": "SPATIAL_COORDINATES_GEOMETRY.E47",
>   "parentid": "80446382-0e96-4db1-8a37-95aca166b785",
>   "entityid": "81b06621-2989-4825-98f3-88ee2ac937b6",
>   "property": "P87",
>   "businesstablename": "geometries"
> }],
> "child_entities": [{
>   "value": "Windsor Square District Non-Contributor",
>   "label": "Windsor Square District Non-Contributor",
>   "child_entities": [],
>   "entitytypeid": "NAME.E41",
>   "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
>   "entityid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",
>   "property": "P1",
>   "businesstablename": "strings"
> }, {
>   "value": "",
>   "label": "",
>   "child_entities": [],
>   "entitytypeid": "PLACE.E53",
>   "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
>   "entityid": "80446382-0e96-4db1-8a37-95aca166b785",
>   "property": "P53",
>   "businesstablename": ""
> }],
> "label": "",
> "date_groups": [],
> "primaryname": "Windsor Square District Non-Contributor",
> "value": "",
> "entitytypeid": "HERITAGE_RESOURCE.E18",
> "domains": [{
>   "conceptid": "a5675b84-fed4-4839-9afa-434be64c3899",
>   "child_entities": [],
>   "label": "Primary",
>   "value": "b171b37b-4c78-4b51-91a9-503541511be4",
>   "entitytypeid": "NAME_TYPE.E55",
>   "parentid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",
>   "entityid": "4bd86b01-a047-4e7a-953a-00d2243e39db",
>   "property": "P2",
>   "businesstablename": "domains"
> }],
> "entityid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
> "property": "",
> "businesstablename": ""}
>
>
> *Here's the DSL:*
>
> {
>   "query": {
> "filtered": {
>   "filter": {
> "and": [
>   {
> "bool": {
>   "should": [],
>   "must_not": [],
>   "must": [
> {
>   "nested": {
> "path": "geometries",
>  

Incorrect results from geo_shape filter

2015-02-19 Thread Alexei Peters
Hey Everyone,

I have a nested document that includes a spatial component that I'm using 
in a spatial query via the geo_shape filter.
I've noticed that the filter consistently returns a result that includes a 
geometry that clearly falls outside the spatial filter.
I've tested the spatial intersection in PostGIS and that correctly returns 
back no result from the same query.

Can anyone else verify this?  We have lots of other MultiPolygon data that 
seems to work just fine.

I'm using the REST api against ES v1.4.1

*Here's the document I'm testing against:*

{"dates": [],
"geometries": [{
  "value": {
"type": "MultiPolygon",
"coordinates": [
  [
[
  [-118.32608,
  34.07035],
  [-118.32657,
  34.07035],
  [-118.32657,
  34.07054],
  [-118.32608,
  34.07054],
  [-118.32608,
  34.07035]
]
  ],
  [
[
  [-118.32608,
  34.07021],
  [-118.32608,
  34.07004],
  [-118.32657,
  34.07004],
  [-118.32657,
  34.07021],
  [-118.32608,
  34.07021]
]
  ]
]
  },
  "label": "MULTIPOLYGON (((-118.32608 34.07035,-118.32657 
34.07035,-118.32657 34.07054,-118.32608 34.07054,-118.32608 
34.07035)),((-118.32608 34.07021,-118.32608 34.07004,-118.32657 
34.07004,-118.32657 34.07021,-118.32608 34.07021)))",
  "child_entities": [],
  "entitytypeid": "SPATIAL_COORDINATES_GEOMETRY.E47",
  "parentid": "80446382-0e96-4db1-8a37-95aca166b785",
  "entityid": "81b06621-2989-4825-98f3-88ee2ac937b6",
  "property": "P87",
  "businesstablename": "geometries"
}],
"child_entities": [{
  "value": "Windsor Square District Non-Contributor",
  "label": "Windsor Square District Non-Contributor",
  "child_entities": [],
  "entitytypeid": "NAME.E41",
  "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
  "entityid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",
  "property": "P1",
  "businesstablename": "strings"
}, {
  "value": "",
  "label": "",
  "child_entities": [],
  "entitytypeid": "PLACE.E53",
  "parentid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
  "entityid": "80446382-0e96-4db1-8a37-95aca166b785",
  "property": "P53",
  "businesstablename": ""
}],
"label": "",
"date_groups": [],
"primaryname": "Windsor Square District Non-Contributor",
"value": "",
"entitytypeid": "HERITAGE_RESOURCE.E18",
"domains": [{
  "conceptid": "a5675b84-fed4-4839-9afa-434be64c3899",
  "child_entities": [],
  "label": "Primary",
  "value": "b171b37b-4c78-4b51-91a9-503541511be4",
  "entitytypeid": "NAME_TYPE.E55",
  "parentid": "62a82362-b7c3-4ad2-ba58-29bab7dc5dbb",
  "entityid": "4bd86b01-a047-4e7a-953a-00d2243e39db",
  "property": "P2",
  "businesstablename": "domains"
}],
"entityid": "5fbe787f-8fc3-4986-b77a-38828699b68c",
"property": "",
"businesstablename": ""}


*Here's the DSL:*

{
  "query": {
"filtered": {
  "filter": {
"and": [
  {
"bool": {
  "should": [],
  "must_not": [],
  "must": [
{
  "nested": {
"path": "geometries",
"query": {
  "geo_shape": {
"geometries.value": {
  "shape": {
"type": "Point",
"coordinates": [
  -118.34194465228431,
  34.06402964781424
]
  }
}
  }
}
  }
}
  ]
}
  }
]
  },
  "query": {
"match_all": {}
  }
}
  },
  "from": 0,
  "size": 5
} 



*Here's the mapping for the index:*

  "properties": {
"businesstablename": {
  "index": "not_analyzed",
  "type": "string"
},
"child_entities": {
  "type": "nested",
  "properties": {
"businesstablename": {
  "index": "not_analyzed",
  "type": "string"
},
"entitytypeid": {
  "index": "not_analyzed",
  "type": "string"
},
"property": {
  "index": "not_analyzed",
  "type": "string"
},
"entityid": {
  "index": "not_analyzed",
  "type": "string"
},
"label": {
  "index": "not_analyzed",
  "type": "string"
},
"value": {
  "type": "string",
  "fields": {
"raw": {
  "index": "not_analyzed",
  "type": "string"
},
"folded": {
  "analyzer": "folding",
  "type": "string"
}
  }
},
"parentid": {
  "index": "not_analyzed",
  "type": "string"
}
  }
},
"entitytypeid": {
  "index": "not_analyzed",
  "type":