Reputation: 13
Lets say I have a field called complexId
and it has a value with special characters: fruit/1a.445/2.10.mango
. So when I search for something like Complex ID fruit/1a.445/2.10.mango
, I should be able to get the result.
What I want is, I want elastic search to match at least one among these 3 words:
1. Complex
2. ID
3. fruit/1a.445/2.10.mango
eg:- Below are my two documents:
{
"name": "Joe",
"complexId": "fruit/1a.445/2.10.mango"
},
{
"name": "Matt",
"complexId": "car/35.6a5/chevy.20"
}
The user searches for something like blah blah blah fruit/1a445/mango blah blah
and he should get the below result:
{
"name": "Matt",
"complexId": "fruit/1a.445/2.10.mango"
}
I tried this but it fails to give me any result:
{
"query": {
"bool": {
"match" :
{
complexId : "blah blah blah fruit/1a.445/2.10.mango blah blah"
}
}
}
}
The field complexId
has a standard Analyzer.
Any help would be appreciated.
Upvotes: 1
Views: 448
Reputation: 66
A Standard Analyzer would not work in your case.
Since you are having special characters, it will be ignored while storing into ElasticSearch. Try using the whitespace
Analyzer instead.
POST _analyze
{
"analyzer": "whitespace",
"text": "blah blah blah fruit/1a.445/2.10.mango blah blah"
}
Play around with different Analyzers and find the one that is best suited for your needs.
You could create your own custom Analyzer as well.
Upvotes: 1