Elasticsearch Query if point falls within a list of Geocircles Null pointer exception


(Matthew Hartz) #1

Hi,

I'm trying to determine if a company, which has many locations, services a particular point on the map. I believe i've gotten this query to work once in the past but I can't get it to work currently.

Here is my query, data structure, mapping, and error message. (I've also tried some other queries, but this should be close)

GET corporateoffice/connection/_search
{
"from": 0,
"size": 20,
"query": {
"geo_shape": {
"operatinglocations.servicearea": {
"relation": "within",
"shape": {
"type": "circle",
"coordinates": [
[
-117.75,
33.65
]
]
}
}
}
}
}

{
"_index": "a",
"_type": "b",
"_source": {
"id": "22-21",
"connectionid": 6,
"operatinglocations": [
{
"servicearea": {
"type": "circle",
"radius": "50mi",
"coordinates": [
-117.7536615,
33.6599121
]
}
}
]
}
}

{
"corporateoffice": {
"mappings": {
"connection": {
"properties": {
"connectionid": {
"type": "double"
},
"id": {
"type": "string"
},
"operatinglocations": {
"servicearea": {
"type": "geo_shape"
}
}
},
}
}
}
}
}

{
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": null
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "corporateoffice",
"node": "m8bILPcATemgH1YQ-3-WQA",
"reason": {
"type": "null_pointer_exception",
"reason": null
}
}
]
},
"status": 500
}

I tried cleaning up some of the objects too for clarity.. so there may be some json errors if we take it for perfection.

Thanks!


(Matthew Hartz) #2

Figured it out.

GET corporateoffice/connection/_search
{
"from": 0,
"size": 20,
"query": {
"geo_shape": {
"operatinglocations.servicearea": {
"relation": "contains",
"shape": {
"type": "point",
"coordinates":
[
-120.75,
33.65
]
}
}
}
}
}


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.