elasticsearch-dsl-py: dsl doesn't parser filter correctly

Hello, I have these code:

self.search = self.search.filter(
                'geo_polygon', location={'points': polygon_coordinates}
            )

and these result:

Exception Value: filter() got an unexpected keyword argument 'location'

I have these location index, on _mappings

{
    "myindex_data": {
        "mappings": {
            "my_data": {
                "properties": {
                   "location": {
                        "type": "geo_point"
                    }
                }
            }
        }
    }

So, my issue is: there’s issue on DSL, work with geo_polygon or my command is incorrect?

Thanks!

Regards!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

FacetedSearch has a Search object stored as self._s. In your case you want to, however, override the search method and add any logic in there:

def search(self):
    s = super(MyFacetedSearch, self).search()
    if self.geo_param:
        s = s.filter('geo_polygon', ...)
    return s

What you are doing is overriding a built-in search method with an instance of Search which is not supported and cannot be picked up by the rest of the FacetedSearch code.

Hope this helps