Elasticsearch : Root mapping definition has unsupported parameters index : not_analyzed

后端 未结 5 1117
一生所求
一生所求 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

    0 讨论(0)
  • 2020-12-23 11:26

    Check your Elastic version.

    I had these problem because I was looking at the incorrect version's documentation.

    0 讨论(0)
  • 2020-12-23 11:32

    I hope the above answer works for elastic search <7.0 but in 7.0 we cannot specify doc type and it is no longer supported. And in that case if we specify doc type we get similar error.

    I you are making use of Elastic search 7.0 and Nest C# lastest version(6.6). There are some breaking changes with ES 7.0 which is causing this issue. This is because we cannot specify doc type and in the version 6.6 of NEST they are using doctype. So in order to solve that untill NEST 7.0 is released, we need to download their beta package

    Please go through this link for fixing it

    https://xyzcoder.github.io/elasticsearch/nest/2019/04/12/es-70-and-nest-mapping-error.html

    EDIT: NEST 7.0 is now released. NEST 7.0 works with Elastic 7.0. See the release notes here for details.

    0 讨论(0)
  • 2020-12-23 11:36

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

    If you are using Ruby On Rails this means that you may need to remove document_type from your model or concern.

    As an alternative to mapping types one solution is to use an index per document type.

    Before:

    module Searchable
      extend ActiveSupport::Concern
    
      included do
        include Elasticsearch::Model
        include Elasticsearch::Model::Callbacks
        index_name [Rails.env, Rails.application.class.module_parent_name.underscore].join('_')
        document_type self.name.downcase
      end
    end
    

    After:

    module Searchable
      extend ActiveSupport::Concern
    
      included do
        include Elasticsearch::Model
        include Elasticsearch::Model::Callbacks
        index_name [Rails.env, Rails.application.class.module_parent_name.underscore, self.name.downcase].join('_')
      end
    end
    
    0 讨论(0)
  • 2020-12-23 11:42
    PUT /testIndex
    {
        "mappings": {
            "properties": {     <--ADD THIS
                "field1": {
                    "type": "integer"
                },
                "field2": {  
                    "type": "integer"
                },
                "field3": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "field4": {
                    "type": "string",
                    "analyzer": "autocomplete",
                    "search_analyzer": "standard"
                }
            }
        },
        "settings": {
            bla
            bla
            bla
        }
    }
    

    Here's a similar command I know works:

    curl -v -H "Content-Type: application/json" -H "Authorization: Basic cGC3COJ1c2Vy925hZGFJbXBvcnABCnRl" -X PUT -d '{"mappings":{"properties":{"city":{"type": "text"}}}}' https://35.80.2.21/manzanaIndex
    

    The breakdown for the above curl command is:

    PUT /manzanaIndex
    {
        "mappings":{
            "properties":{
                    "city":{
                        "type": "text"
                    }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题