brewster / elastictastic

Object-document mapper and lightweight API adapter for ElasticSearch
MIT License
88 stars 13 forks source link

Unable to set custom analysers #30

Closed geeky-sh closed 11 years ago

geeky-sh commented 11 years ago

Here is my result of query:

 curl -XGET localhost:9200/_template/template_1  
{"template":"*", "order":0, "settings":{
    "number_of_shards":1,
    "analysis":{
        "tokenizer":{
            "name_tokenizer":{
                "type":"edgeNGram",
                "max_gram":100,
                "min_gram":3,
                "side":"front"
            }
        },
        "analyzer":{
            "name_analyzer":{
                "tokenizer":"whitespace",
                "type":"custom",
                "filter":["lowercase", "multi_words", "name_filter"]
            },
            "lower_keyword":{
                "tokenizer":"keyword",
                "type":"custom",
                "filter":["lowercase"]
            },
            "multi_words":{
                "tokenizer":"standard",
                "type":"custom",
                "filter":["standard", "lowercase", "stop", "multi_words"]
            }
        },
        "filter":{
            "multi_words":{
                "type":"shingle",
                "min_shingle_size":2,
                "max_shingle_size":1
            },
            "name_filter":{
                "type":"edgeNGram",
                "max_gram":100,
                "min_gram":3,
                "side":"front"
            },
            "name_filter_reverse":{
                "type":"edgeNGram",
                "max_gram":100,
                "min_gram":3,
                "side":"back"
            }
        }
    }
}, "mappings":{
    "type1":{
        "_source":{
            "enabled":false
        }
    }
}}

Now, I can use analysers - "name_analyzer" for a field in elastictastic document. Here is my model class

tag.rb

field :tag_value, type: 'string', index: 'analyzed', analyzer: 'name_analyzer' do
  field :tag_value_lower, type: 'string', index: 'analyzed', analyzer: 'lower_keyword'
  field :tag_value_untouched, type: 'string', index: 'not_analyzed'
end

When I perform:

Tag.sync_mapping

I get the following error:

Elastictastic::ServerError::MapperParsingException: [Analyzer [name_analyzer] not         found for field [tag_value]]
from /home/geeky-sh/.rvm/gems/ruby-1.9.3-p327/bundler/gems/elastictastic-0652e1cf11ff/lib/elastictastic/middleware.rb:75:in `raise_error'

Any reasons on why I am unable to set mappings using my custom analyzers?