I have a name field that is indexed using the english
analyzer that contains part names (also tried the standard analyzer).
The problem I have is some of my titles contain punctuation, some do not. Also, some of my queries contain punctuation and some do not.
For example I have the title "CenterG 5.2 Drive Belt for model number 4425". My query could look like this: "Centerg 5.2 belt" and if it does, then my results display correctly with the "CenterG 5.2 Drive Belt for model number 4425" at the top.
However, if my query does not contain punctuation, the product does not display in the results. I have the same problem for titles that don't contain punctuation and queries that do. I'm not sure how this should be handled. I tried using the standard
analyzer which I understand disregards punctuation, but that did not improve the results. They were roughly the same.
So, when I search for "CenterG 5.2 Belt" or "centerg 52 belt", I want the product "CenterG 5.2 Drive belt for model number 4425" to display at the top of my results.
Here is my mapping:
{:properties=>{:name=>{:type=>"text", :analyzer=>"english"}}
I have also tried leveraging an ngram analyzer which did not fix this problem.
Here is my query:
{
query: {
bool: {
should:
{
multi_match:{
fields: ["name"],
query: "#{query}"
}
}
}
}
}