I'm working on a product search with Elasticsearch 7.3. The product titles are not formatted the same but there is nothing I can do about this.
Some titles might look like this:
Ford Hub Bearing
And others like this:
Hub bearing for a Chevrolet Z71 - model number 5528923-01
If someone searches for "Chevrolet Hub Bearing" the "Ford Hub Bearing" product ranks #1 and the Chevrolet part ranks #2. If I remove all the extra text (model number 5528923-01) from the product title, the Chevrolet part ranks #1 as desired.
Unfortunately I am unable to fix the product titles, so I need to be able to rank the Chevrolet part as #1 when someone searches Chevrolet Hub Bearing
. I have simply set the type of name
to text
and applied the standard
analyzer in my index. Here is my query code:
{
query:{
bool: {
must: [
{
multi_match:{
fields:
[
'name'
],
query: "Chevrolet Hub Bearing"
}
}
]
}
}
}