Upgrading from ES 1.7 to 5.4; default mapping analyzer


(Karoline Brynildsen) #1

I am in the process of moving our indexes from ES 1.7 to ES 5.4, and I am encountering a problem that I am not sure how to solve.

In my old index I have this mapping on a type:

{
  "myType1": {
    "search_analyzer": "default_search_myType1",
    "index_analyzer": "default_index_myType1",
    "properties": {...}
}

When I try to create this mapping in ES 5.4, I get the error message that I cannot set analyzer and search_analyzer on the root of the type.
So how do I define which analyzer to use for this type?


(David Pilato) #2

Define it per field instead. You can use a template for that.


(Karoline Brynildsen) #3

Do you mean this?
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html

I also read that if you define an analyzer named "default" and/or "default_search" in your index settings this will be the default analyzer for the index. But this does not seem to work for me...

EDIT: I figured it out :slight_smile:


(David Pilato) #4

The default analyzer works well for me:

DELETE mytest
PUT mytest
{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "custom",
          "tokenizer": "keyword"
        }
      }
    }
  }
}

POST mytest/doc
{
  "foo": "FOO BAR"
}

GET mytest/_search
{
  "query": {
    "term": {
      "foo": {
        "value": "FOO BAR"
      }
    }
  }
}

This is producing the expected result.

EDIT: just saw that you edited your answer :slight_smile:


(Karoline Brynildsen) #5

I solved it by changing the name of the analyzers in the settings to "default" and "default_search" :slight_smile:

At first I thought it did not work, but when I examined the mappings closed I saw that I had defined "analyzer: standard" on the field I was trying to query... I removed that form the mappings and then everything worked as expected.

Thanks for the help!


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.