Dear All,
I'm using: Elasticsearch version: 5.2
My index mapping contains:
'bbox': {'type': 'geo_shape', 'precision': '10km', 'tree': 'quadtree', },
A Python script inserts in Elastic the area_of_interest object fields, and the bbox insertion is:
if area_of_interest.bbox_minx is not None:
doc['bbox'] = {
"type": "envelope",
"coordinates": [[obj.bbox_minx, obj.bbox_maxy], [obj.bbox_maxx, obj.bbox_miny]],
}
else:
doc['bbox'] = None
Of course all bbox fields (bbox_minx, bbox_maxy, bbox_maxx, bbox_miny) are evaluated or None (null in Elastic is inserted).
The insertion works:
# station with bbox evaluated
{
"_index": "place-20170317-054435",
"_type": "placelayer",
"_id": "1962",
"_version": 1,
"found": true,
"_source": {
"id": 1962,
"lang": "id",
"bbox": {
"type": "envelope",
"coordinates": [[-119.6928, 34.4031], [-119.6928,34.4031]]
},
"modified": "2017-03-15T15:05:06.678083+00:00",
"created": "2017-03-15T15:05:06.677892+00:00",
"name": "station test 33333",
"description": "desc station 33333",
}
}
# station with bbox to null
{
"_index": "place-20170317-054435",
"_type": "placelayer",
"_id": "2390",
"_version": 1,
"found": true,
"_source": {
"id": 2390,
"lang": "",
"bbox": null,
"modified": "2017-03-17T04:57:27.781646+00:00",
"created": "2017-03-17T04:57:27.519688+00:00",
"name": "station test 19383",
"description": "desc station 19383",
}
}
While querying I got this EXCEPTION:
GET /places/placelayer/_search
{
"query": {
"bool" : {
"must" : {
"match_all" : {}
},
"filter" : {
"geo_bounding_box" : {
"bbox" : {
"top_left" : {
"lat" : 40.73,
"lon" : -74.1
},
"bottom_right" : {
"lat" : 40.01,
"lon" : -71.12
}
}
}
}
}
}
}
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.RequestError: TransportError(400, 'search_phase_execution_exception', 'field [bbox] is not a geo_point field')
My field called bbox is a 'type': 'geo_shape', and sincerely I don't understand the reason for the exception.
Thanks,
D