Tried:
query = query.filter('range', **{'field.name': {'lt': 1.22}})
always comes up with empty results
For nested fields you need to use nested filters:
query = query.filter('nested', path='field', filter=F('range', field__name={'lt': 1.22}))
Note also that you can use double underscore instead of . to avoid having to use the **{} construct.
Hope this helps.
thanks! already figured that out
@HonzaKral : is there any way to query fields which are not nested using F object notations?
basically i want something like
query = query.filter('match', filter=F('fs.mount_point': '/'))
@siddhism you can either use python's ** expansion (query.filter('match', **{"fs.mount_point": "/"})) or use the fact that elasticsearch-dsl will expand __ to dot: query.filter('match', fs__mount_point='/')
Hi, I am using elasticsearch 5.4.0 and elasticsearch-dsl 5.3.0
I am trying the above command
s = Search().using(client).index("my_index").filter("nested", path="comment", filter=filter("range", comment__comment_value={'gte':"1"}))
It returns
TypeError: filter() does not take keyword arguments
What am I doing wrong ?
Also, I can't seem to find F shortcut ... is it deprecated ?
I think you are missing an underscore in comment__comment_value, which should read comment__comment__value.
And yes, if I am not mistaken, the F is deprecated (see changelog)
Most helpful comment
For nested fields you need to use nested filters:
Note also that you can use double underscore instead of
.to avoid having to use the**{}construct.Hope this helps.