Elasticsearch : Root mapping definition has unsupported parameters index : not_analyzed

后端 未结 5 1189
一生所求
一生所求 2020-12-23 11:17

Hi all I am trying to create schema Test.

PUT /test
{
    \"mappings\": {
        \"field1\": {
            \"type\": \"integer\"
        },
        \"field         


        
5条回答
  •  不思量自难忘°
    2020-12-23 11:26

    You're almost here, you're just missing a few things:

    PUT /test
    {
      "mappings": {
        "type_name": {                <--- add the type name
          "properties": {             <--- enclose all field definitions in "properties"
            "field1": {
              "type": "integer"
            },
            "field2": {
              "type": "integer"
            },
            "field3": {
              "type": "string",
              "index": "not_analyzed"
            },
            "field4,": {
              "type": "string",
              "analyzer": "autocomplete",
              "search_analyzer": "standard"
            }
          }
        }
      },
      "settings": {
         ...
      }
    }
    

    UPDATE

    If your index already exists, you can also modify your mappings like this:

    PUT test/_mapping/type_name
    {
        "properties": {             <--- enclose all field definitions in "properties"
            "field1": {
              "type": "integer"
            },
            "field2": {
              "type": "integer"
            },
            "field3": {
              "type": "string",
              "index": "not_analyzed"
            },
            "field4,": {
              "type": "string",
              "analyzer": "autocomplete",
              "search_analyzer": "standard"
            }
        }
    }
    

    UPDATE:

    As of ES 7, mapping types have been removed. You can read more details here

提交回复
热议问题