Custom Analyzer elasticsearch-rails -
Custom Analyzer elasticsearch-rails -
i'm using elasticsearch-rails gem in rails app simplify integration elasticsearch. i'm trying utilize phonetic analysis plugin, need define custom analyzer , custom filter index.
i tried piece of code in order perform custom analysis soundex phonetic filter, fails exception message:
[!!!] error when creating index: elasticsearch::transport::transport::errors::badrequest [400] {"error":"mapperparsingexception[mapping [call_sentence]]; nested: mapperparsingexception[analyzer [{tokenizer=standard, filter=[standard, lowercase, metaphoner]}] not found field [phonetic]]; ","status":400}
# set index configuration , mapping # settings index: { number_of_shards: 1, number_of_replicas: 0 } mapping indexes :text, type: 'multi_field' indexes :processed, analyzer: 'snowball' indexes :phone, {analyzer: { tokenizer: "standard", filter: ["standard", "lowercase", "metaphoner"] }, filter: { metaphoner: { type: "phonetic", encoder: "soundex", replace: false } }} indexes :raw, analyzer: 'keyword' end end end
you can specify in settings call:
settings index: { number_of_shards: 1, number_of_replicas: 0, analysis: { filter: { metaphoner: { type: 'phonetic', encoder: doublemetaphone, replace: true, } }, analyzer: { phonetic_analyzer: { tokenizer: 'standard', filter: ["standard", "lowercase", "metaphoner"], } } } } mapping indexes :text, type: 'multi_field' indexes :processed, analyzer: 'snowball' indexes :phone, analyzer: 'phonetic_analyzer' indexes :raw, analyzer: 'keyword' end end end
ruby-on-rails elasticsearch elasticsearch-plugin
Comments
Post a Comment