Using elasticsearch-dsl, I'm trying to search for the closest match to a company name, but to exclude exact matches.
For example, I want to search for names similar to 'Greater London Authority (GLA)', but I want all exact matches to be either filtered out or given a significant downgrading in the score.
To clarify, in my index I know that the string 'Greater London Authority' exists, and would like this to be returned as being a better result than the original string (also in the index)
Currently I have:
mn = Q({
"bool": {
"must_not": [
{
"match": {
"buyer": entity_name
}
}
]
}
}
)
s = Search(using=es, index="ccs_notices9") \
.query("match", buyer=entity_name)\
.query(mn)
results = s.execute(s)
results.to_dict()
But I get no results, which makes sense as I'm basically reversing the two queries. I've tried to use "term" in place of "match" in the mn query, but this isn't allowed. I've also tried a more simpler :
s = Search(using=es, index="ccs_notices9") \
.query("match", buyer=entity_name)\
.exclude("term", buyer=entity_name)
Which does give me results, but the string above is still included.