elasticsearch - 验证失败 : 1: mapping type is missing; in elasticsearch

标签 elasticsearch lucene

我也是一个错误 this questuion . 作为这个问题的答案,我正在尝试将正确的 url 设置为 PUT 索引映射,但它在我的实例上不起作用:

$ cat mapping.json | http PUT myhost:9200/acastest/_mapping 

结果:

HTTP/1.1 400 Bad Request
Content-Length: 247
Content-Type: application/json; charset=UTF-8

{
    "error": {
        "reason": "Validation Failed: 1: mapping type is missing;", 
        "root_cause": [
            {
                "reason": "Validation Failed: 1: mapping type is missing;", 
                "type": "action_request_validation_exception"
            }
        ], 
        "type": "action_request_validation_exception"
    }, 
    "status": 400
}

并尝试这样做:

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 

结果:

HTTP/1.1 400 Bad Request
Content-Length: 3969
Content-Type: application/json; charset=UTF-8

{
    "error": {
        "reason": "Root mapping definition has unsupported parameters:  [mappings : {articles={properties={category_en={type=string, index=not_analyzed},blah blah blah", 
        "root_cause": [
            {
                "reason": "Root mapping definition has unsupported parameters:  [mappings : {articles={properties={category_en={type=string, index=not_analyzed}, category_fa={blahblah blah", 
                "type": "mapper_parsing_exception"
            }
        ], 
        "type": "mapper_parsing_exception"
    }, 
    "status": 400
}

Elasticsearch 配置:

"version": {

    "number": "2.1.1",
    "build_hash": "40e2c53a6b6c2972b3d13846e450e66f4375bd71",
    "build_timestamp": "2015-12-15T13:05:55Z",
    "build_snapshot": false,
    "lucene_version": "5.3.1"

},

我的映射文件是这样的:

{ 
    "mappings": {
            "articles": {
                "properties": {
                    "category_en": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "category_fa": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    blah
                    blah
                    blah
                }
            }
        }
}

要查看完整的映射文件,请检查 this 我该如何解决?

最佳答案

您有两个解决方案:

一个。如果你想运行

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 

您需要像这样更改您的 mapping.json 文件:

    { 
        "articles": {
            "properties": {
                "category_en": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "category_fa": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                blah
                blah
                blah
            }
        }
    }

B.或者您可以像现在一样保留您的 mapping.json 文件,但是您需要改为运行以下命令:

$ cat mapping.json | http PUT myhost:9200/acastest 

关于elasticsearch - 验证失败 : 1: mapping type is missing; in elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35814080/

相关文章:

json - Java 使用 apache http 将 json 文件发布到 elasticsearch

elasticsearch - ElasticSearch查询未返回数组的完全匹配

django - Elasticsearch和auto_query

lucene - Neo4j:使用 Cypher 进行 Lucene 短语匹配(模糊)

java - 从 Lucene 3.0 迁移到 4.9.0

Java-无法将目录变量作为参数传递给 Apache Lucene 6.4.2 中的 IndexReader.open()

elasticsearch - Elasticsearch快照

elasticsearch - 使用C#NEST增加弹性体的磁场极限

java - lucene只能排序搜索什么都不行吗?

elasticsearch - 为什么全局序数是建立在字段数据而不是 doc_values 上的?