[ES 2.4.4] multi_field type and completion suggester


(sr) #1

Elasticsearch version: ES 2.4.4

Plugins installed: [None]

JVM version: Java(TM) SE Runtime Environment (build 1.8.0_77-b03)

OS version: Red Hat Enterprise Linux Server release 6.7 (Santiago) - 2.6.32-642.15.1.el6.x86_64

Description of the problem including expected versus actual behavior:

I am working on an elasticsearch upgrade project. (From version 0.90.11 to 2.4.4)

I am facing issue with multi_field type and completion suggester.

A multi_field type with one field of type completion is getting mapped differently in version 2.4.4.

e.g.: ES 0.90.11

{
    "test_index": {
        "item": {
            "properties": {
                "state": {
                    "type": "multi_field",
                    "fields": {
                        "suggest": {
                            "type": "completion",
                            "analyzer": "whitespace",
                            "payloads": false,
                            "preserve_separators": true,
                            "preserve_position_increments": true,
                            "max_input_len": 50
                        }
                    }
                }
            }
        }
    }
}

e.g.: ES 2.4.4

{
    "test_index": {
        "mappings": {
            "item": {
                "properties": {
                    "state": {
                        "type": "completion",
                        "analyzer": "simple",
                        "payloads": false,
                        "preserve_separators": true,
                        "preserve_position_increments": true,
                        "max_input_length": 50,
                        "fields": {
                            "suggest": {
                                "type": "completion",
                                "analyzer": "whitespace",
                                "payloads": false,
                                "preserve_separators": true,
                                "preserve_position_increments": true,
                                "max_input_length": 50
                            }
                        }
                    }
                }
            }
        }
    }
}

ES version 2.4.4 automatically map ‘state’ property as completion type and default to simple analyzer.

Questions

  • Is this the expected behavior?

  • What are the benefits of having 'fields' in Completion type?
    With the above mapping how the indexing work for input

PUT test_index/item/1
{
  "state": {
    "input": [ "NC", "North Carolina" ],
    "output": "North Carolina"
  }
}

  • Is there any way I can retain the 0.90.11 search behavior in 2.4.4. So that I can keep using the same DSL?
POST test_index/_suggest
{
  "stateNameSuggest": {
    "text": "NC",
    "completion": {
      "field": "state.suggest"
    }
  }
}

Steps to reproduce:

  1. Create Index
POST test_index
{
  "mappings": {
    "item": {
      "properties": {
        "state": {
          "type": "multi_field",
          "fields": {
            "suggest": {
              "type": "completion",
              "analyzer": "whitespace",
              "search_analyzer": "whitespace"
            }
          }
        }
      }
    }
  }
}
  1. Load test data
PUT test_index/item/1
{
  "state": {
    "input": [ "NC", "North Carolina" ],
    "output": "North Carolina"
  }
}

  1. Test - Completion Suggestion
    (Works in 0.90.11 but not in 2.4.4)
POST test_index/_suggest
{
  "stateNameSuggest": {
    "text": "NC",
    "completion": {
      "field": "state.suggest"
    }
  }
}


(system) #2

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