1

Currently i am evaluating if and how a legacy lucene-based analyzer component can be moved to elastic search (0.19.18). Since the legacy code is based on lucene i wrapped the analyzer in an es-plugin. The analyzer's configuration looks like the following lines:

index.analysis.analyzer.myAnalyzer.type : myAnalyzer
index.analysis.analyzer.default.type: myAnalyzer
index.analysis.analyzer.default_index.type: myAnalyzer
index.analysis.analyzer.default_search.type: myAnalyzer

So far so good.

curl -XGET 'localhost:9200/_analyze' -d 'Some text'

Would return an object that contains the correctly tokenized text, but

curl -XGET 'localhost:9200/<name-of-my-index>/_analyze' -d 'Some text'

would return a text, that is not tokenized at all. Obviously, instead of myAnalyzer only the lower case filter is applied. The objects in the index are neither correctly analyzed.

The index mappings look like this (output from head-plugin):

mappings: {
item: {
    analyzer: myAnalyzer
    properties: {
        id: {
            type: string
        }
        itemnumber: {
            type: string
        }
        articletext: {
            analyzer: myAnalyzer
            type: string
        }
        sortvalue: {
            type: string
        }
        salesstatus: {
            format: dateOptionalTime
            type: date
        }
    }
}
}

Since i am new to ES, i can't figure out, what the reason for this behaviour actually is. Is there somebody with an idea?

3
  • What do you get when you run curl -XGET 'localhost:9200/<name-of-my-index>/_settings' ? Commented Jul 16, 2012 at 18:46
  • {"myIndex":{"settings":{"index.version.created":"190899","index.number_of_replicas":"0","index.number_of_shards":"1"}}} Commented Jul 17, 2012 at 7:49
  • Is it possible to post a repro somewhere? Commented Jul 18, 2012 at 16:27

1 Answer 1

2

This how I set a custom default analyzer in Elasticsearch.

index:
  analysis:
    analyzer:
      default:
        filter: [lowercase]
        tokenizer: whitespace
        type: custom

Works like a charm.

Sign up to request clarification or add additional context in comments.

2 Comments

I stumbled upon your answer, was trying to use an custom already-defined analyzer in "type" e.g. "french2" and "custom" made it! Thanks.
just to emphasis, the key is to use 'default' as the custom analyzer name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.