Elasticsearch-dsl-py: Is it possible to define contexts for a field of Completion type?

Created on 17 Nov 2016  路  2Comments  路  Source: elastic/elasticsearch-dsl-py

I need to define a context for a Completion field. Is it possible to do it using elasticsearch-dsl? Because I need to limit context of completion suggester using another field (user_id) defined in my mapping.

Most helpful comment

Sure, just pass in the contextx:

auto_complete = Completion(contexts=[{"name": "color", "type": "category", "path": "color"}])

Hope this helps

All 2 comments

Sure, just pass in the contextx:

auto_complete = Completion(contexts=[{"name": "color", "type": "category", "path": "color"}])

Hope this helps

Hi, I tried the exact example (except assign the results to a variable called suggest versus to_complete) above using elasticsearch-dsl version 2.2.0 with Elastic Search version 2.3.4 and received an error below. Any thoughts on why this may be happening?

Thanks,
Mike

TransportError(400, 'mapper_parsing_exception', 'Mapping definition for [suggest] has unsupported parameters: [contexts : [{path=color, name=color, type=category}]]'

Was this page helpful?
0 / 5 - 0 ratings