Unable to set custom analysers

16 views
Skip to first unread message

aash dhariya

unread,
Dec 28, 2012, 3:03:32 PM12/28/12
to elasti...@googlegroups.com
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?

Matthew A. Brown

unread,
Dec 28, 2012, 7:09:54 PM12/28/12
to elasti...@googlegroups.com
Did you get this sorted out? I noticed you opened an issue and then closed it. Anyway, one thing that comes to mind is that you need to create your index *after* setting up your template -- is that the order you did things in?
--
 
 

aash dhariya

unread,
Dec 29, 2012, 1:05:48 AM12/29/12
to elasti...@googlegroups.com
These are the steps that were followed by me:
1. Deleting the template that I already have:
    curl -XDELETE localhost:9200/_template/template_1
2. Deleting the previous elastictastic documents and its index:
Tag.destroy_all
3. Resetting the template:
curl -XPUT localhost:9200/_template/template_1 -d '#{json data}'
4. Checking if the template is set:
curl -XGET localhost:9200/_template/template_1
# template is set
5. Sync mapping now:
Tag.sync_mapping

Are there any other steps that I am missing?


--
 
 



--
Thanks, 
Aash

Matthew A. Brown

unread,
Dec 29, 2012, 9:28:24 AM12/29/12
to elasti...@googlegroups.com
Hi Aash,

Yes -- step 2 doesn't actually delete the index; it just destroys all the Tag documents in the index. You'll need to do curl -XDELETE localhost:9200/my_index as step 2.5. That way when you re-create the index, it will take the settings from your template.

Mat


--
 
 

aash dhariya

unread,
Dec 30, 2012, 12:35:36 AM12/30/12
to elasti...@googlegroups.com
That worked!. Thanks a lot


--
 
 



--
Thanks, 
Aash
Reply all
Reply to author
Forward
0 new messages