I'm trying to order the results of a search such as the most frequent term is the one with the highest score.
For instance, given these documents:
doc_1 = {'abb':['foo']}
doc_2 = {'abb':['foo', 'bar']}
doc_3 = {'abb':['foo', 'bar', 'foo']})
doc_4 = {'abb':['foo', 'foo', 'foo']})
or
doc_1 = {'abb':{'foo': 1}}
doc_2 = {'abb':{'foo': 1, 'bar': 1}}
doc_3 = {'abb':{'foo': 2, 'bar': 1}}
doc_4 = {'abb':{'foo': 3}}
How can I manage to get as top answer the document with the most occurence of a given field (here foo
where the best match would be doc_4
) ?
Eg. this query (without boosting here): 'query': { 'match': {'abb': 'foo'}}