索引期间Elasticsearch不支持的参数

时间:2016-10-04 00:51:05

标签: elasticsearch

运行以下命令curl -XPUT localhost:9200/alpha/_mapping/gremlin -d @company_info_mapping.json会返回带有400消息的Root mapping definition has unsupported parameters

这是映射文件:

{
    "settings": {
    "index.mapping.ignore_malformed": true,
    "analysis" : {
        "index_analyzer": {
            "my_index_analyzer" : {
                "type": "custom",
                "tokenizer" : "standard",
                "filter" : ["lowercase", "mynGram"]
            }
        },
        "search_analyzer": {
            "my_search_analyzer": {
                "type": "custom",
                "tokenizer": "standard",
                "filter" : ["standard", "lowercase", "mynGram"]
            }
        },
        "filter": {
            "mynGram": {
                "type": "nGram",
                "min_gram": 2,
                "max_gram": 30
            }
        }
    }
  },

  "mappings": {
    "company_info": {
        "properties": {
            "company" : {"type" : "string"},
            "description": {"type": "string"},
            "founded": {"type": "string"},
            "headquartes": {"type": "string"},
            "industry": {"type": "string"},
            "numberOfEmployees": {"type": "string"},
            "size": {"type": "string"},
            "specialties": {"type": "string"},
            "typ": {"type" : "string"},
            "website": {"type" : "string"},
            "domain" : {"type": "string"},
            "link": {"type" : "string"},
            "linkedinId": {"type": "string"},
            "linkedinUrl": {"type": "string"},
            "title": {"type": "string"},
            "people":{"properties":{"email":{"type":"string"},"id":{"type":"string"},"linkedinId":{"type":"string"},"linkedinUrl":{"type":"string"},"name":{"type":"string"},"title":{"type":"string"},"twitter":{"type":"string"},"verifiedEmail":{"type":"string"}}}
        }
    }
  }
}

1 个答案:

答案 0 :(得分:1)

上面的JSON包含settingsmappings,您正在点击_mapping端点。如果您的alpha索引已存在并且您想要更新其映射,则可以使用以下内容运行以下命令:

curl -XPUT localhost:9200/alpha/_mapping/gremlin --data-binary @company_info_mapping.json

company_info_mapping.json

{
   "properties": {
        "company" : {"type" : "string"},
        "description": {"type": "string"},
        "founded": {"type": "string"},
        "headquartes": {"type": "string"},
        "industry": {"type": "string"},
        "numberOfEmployees": {"type": "string"},
        "size": {"type": "string"},
        "specialties": {"type": "string"},
        "typ": {"type" : "string"},
        "website": {"type" : "string"},
        "domain" : {"type": "string"},
        "link": {"type" : "string"},
        "linkedinId": {"type": "string"},
        "linkedinUrl": {"type": "string"},
        "title": {"type": "string"},
        "people":{"properties":{"email":{"type":"string"},"id":{"type":"string"},"linkedinId":{"type":"string"},"linkedinUrl":{"type":"string"},"name":{"type":"string"},"title":{"type":"string"},"twitter":{"type":"string"},"verifiedEmail":{"type":"string"}}}
    }
}

如果要更新现有索引的设置,请使用以下命令点击_settings端点:

curl -XPUT localhost:9200/alpha/_settings --data-binary @index_settings.json

index_settings.json

{
"index.mapping.ignore_malformed": true,
"analysis" : {
    "index_analyzer": {
        "my_index_analyzer" : {
            "type": "custom",
            "tokenizer" : "standard",
            "filter" : ["lowercase", "mynGram"]
        }
    },
    "search_analyzer": {
        "my_search_analyzer": {
            "type": "custom",
            "tokenizer": "standard",
            "filter" : ["standard", "lowercase", "mynGram"]
        }
    },
    "filter": {
        "mynGram": {
            "type": "nGram",
            "min_gram": 2,
            "max_gram": 30
        }
    }
  }
}