i have batch of "smartphones" products in es , need query them using "smart phone" text. m looking compound word token filter. , m planning use custom filter this:
curl -xput 'localhost:9200/_all/_settings -d ' { "analysis" : { "analyzer":{ "second":{ "type":"custom", "tokenizer":"standard", "filter":["myfilter"] } "filter": { "myfilter" :{ "type" : "dictionary_decompounder" "word_list": ["smart", "phone"] } } } } } '
is correct approach ? d ask how can create , add custom analyser es? looked several links couldn't figure out how it. guess m looking correct syntax. thank you
edit
i m running 1.4.5 version. , verified custom analyser added successfully:
{ "test_index" : { "settings" : { "index" : { "creation_date" : "1453761455612", "analysis" : { "filter" : { "myfilter" : { "type" : "dictionary_decompounder", "word_list" : [ "smart", "phone" ] } }, "analyzer" : { "second" : { "type" : "custom", "filter" : [ "lowercase", "myfilter" ], "tokenizer" : "standard" } } }, "number_of_shards" : "5", "number_of_replicas" : "1", "version" : { "created" : "1040599" }, "uuid" : "xookedmbr260dnwygn_zqa" } } } }
your approach looks good, consider adding lowercase token filter, smartphone (notice uppercase 's') split smart , phone.
then create index analyzer this,
curl -xput 'localhost:9200/your_index -d ' { "settings": { "analysis": { "analyzer": { "second": { "type": "custom", "tokenizer": "standard", "filter": [ "lowercase", "myfilter" ] } }, "filter": { "myfilter": { "type": "dictionary_decompounder", "word_list": [ "smart", "phone" ] } } } }, "mappings": { "my_type": { "properties": { "name": { "type": "string", "analyzer": "second" } } } } } '
here creating index named your_index, custom analyzer
named second , applied name field.
you can check if analyzer working expected analyze api this
curl -xget 'localhost:9200/your_index/_analyze' -d ' { "analyzer" : "second", "text : "lg android smartphone" }'
hope helps!!
Comments
Post a Comment