What is the best way to use FunctionScore with other queries? I ended up doing something like this:
f = {
'gauss': {
'location_point': {
'origin': {
'lat': lat,
'lon': lng
},
'offset': '1mi',
'scale': '5mi'
}
}
}
fs = FunctionScore(functions=[f])
fs_query = {
'query': fs.to_dict()
}
fs_query['query']['function_score'].update(search.to_dict()) # Adding query info here
fs_search = search.from_dict(fs_query) # New search object from dict
There is a SF shortcut for ScoreFunction creation that might make it easier:
# instyantiate search
s = Search()
# create your query
s = s.query()....
# wrap the query in function score
s.query = FunctionScore(query=s.query, functions=[SF('gauss', location_point={'origin': ..., 'offset': ...})])
Hope this helps
That worked. Thanks.
is FunctionScore documented at all in this lib? What about using a script (ScriptScore)?
Most helpful comment
is FunctionScore documented at all in this lib? What about using a script (ScriptScore)?