Field bbox is not a geo_point field

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

Here: Geo Bounding Box Query | Elasticsearch Guide [5.2] | Elastic

The filter requires the geo_point type to be set on the relevant field.

In your case it's a geo_shape

Davide, thanks a lot for replying!

Based on this comment
https://github.com/elastic/elasticsearch-dsl-py/issues/427 I was wrongly
doing

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
                    }
                }
            }

        }
    }
}

}

But it doesn't work:

    "type": "query_shard_exception",
    "reason": "field [bbox] is not a geo_point field",

While it works using:

GET /places/placelayer/_search
{
"query": {
"geo_shape": {
"bbox": {
"shape": {
"type": "envelope",
"coordinates": [[0, 50],[2, 40]]
}
}
}
}
}

Or using elasticsearch-dsl-py:

(
# bbox_minx:{0}, bbox_miny:{1}, bbox_maxx:{2}, bbox_maxy:{3}
bbox_param = bbox_param.split(',')
if len(bbox_param) != 4:
raise ValidationError(_('Invalid bounding box.'))

    d = {
        'shape': {
            'type': 'envelope',
            'coordinates': [[bbox_param[0], bbox_param[1]],

[bbox_param[2], bbox_param[3]]]
}
}
queryset = queryset.filter('geo_shape', bbox=d)

)

D

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