Reputation: 11
i want to implement a search engine for my online shopping site
i test a few analyzers but i didn't see significance difference between them.i used snowball,ngram,standard analyzers
i don't know for the products name which analyzer suits and give me the best results,also i don't know which search query i should use
this is my schema for mapping
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "standard",
"filter": ["standard", "lowercase", "stop", "kstem", "ngram"]
}
}
}
}
,
"mappings": {
"products": {
"properties": {
"id": {
"type": "integer",
"index": "no"
},
"name": {
"type": "multi_field",
"fields": {
"name": {
"type": "string"
},
"snowball": {
"type": "string",
"analyzer": "snowball"
},
"autocomplete": {
"analyzer": "autocomplete",
"type": "string"
}
}
}
}
}
}
and search query,i don't know using match query is good or not for my usecase
{
"query": {
"multi_match": {
"fuzziness":2,
"type" : "phrase",
"query": "term",
"fields": ["name", "name.snowball",
"name.autocomplete"]
}
}
}
Upvotes: 1
Views: 862
Reputation: 5924
Use the Analyze API to see what tokens are generated in the Lucene index for the different analyzers that you use. The query 'term' is not a good example to test with, use something a bit longer.
What are the requirements for your search?
Don't use the multi-match query to test the results, test the analyzers in individual searches.
curl -XGET 'http://localhost:9200/yourindex/_search?q=name:yourSearchTerm'
curl -XGET 'http://localhost:9200/yourindex/_search?q=name.snowball:yourSearchTerm'
curl -XGET 'http://localhost:9200/yourindex/_search?q=name.autocomplete:yourSearchTerm'
For autocomplete have a look at the Completion Suggesster API.
Also, the Snowball stemmer is quite aggressive and can produce undesirable results, you may want to use a lighter stemmer.
Upvotes: 0