简体   繁体   English

ElasticSearch 7 和 Kibana 意外行为

[英]ElasticSearch 7 & Kibana unexpected behavior

I am trying to store a data into elastic search index the data of a column look as below我正在尝试将数据存储到弹性搜索索引中,列的数据如下所示

C ID 

1234
5678
NA
123D D5614 A7890 

Now I know this data is kind of mixed and so I have selected the text field for this with below properties现在我知道这些数据是混合的,所以我选择了具有以下属性的文本字段

"mappings": {
    "properties":{
         "C ID":{"type":"text" , "fields" :{'keyword': {'type':'keyword'}}},
         
     }
}

Even after this I am always getting the error.即使在此之后,我也总是收到错误消息。 failed to parse field[C ID] of type long in document id 4无法解析文档 id 4 中 long 类型的字段 [C ID]

Please help me out with this.这个你能帮我吗。 I have not given any reference of long don't know why I am getting this error我没有给出任何参考很久不知道为什么我收到这个错误

Update更新

My code base我的代码库

from elasticsearch import Elasticsearrch 

ESConnector is a class responisble for kerberos login. ESConnector 是一个负责 kerberos 登录的类。 We are calling Elasticsearch under ESConnector class我们在 ESConnector 类下调用 Elasticsearch

es = ESConnector()

if not  ex.indices.exist(INDEX):
     set = {"settings":{"index":{"number_of_shards":1, "number_of_replicas":1}} 

     es.indices.create(INDEX, body = set)


mbody =   {
  "mappings": {
        "properties":{
             "C ID":{"type":"text" , "fields" :{'keyword': {'type':'keyword'}}},
             
         }
    }
}

es.indices.put_mapping(INDEX, body = mbody)

You can create the index with the mapping in a single call您可以在一次调用中使用映射创建索引

if not es.indices.exist(INDEX):
    body = {
      "settings": {
        "index": {
          "number_of_shards": 1,
          "number_of_replicas": 1
        }
      },
      "mappings": {
        "properties": {
          "C ID": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword"
              }
            }
          }
        }
      }
    }

    es.indices.create(INDEX, body = body)

It should work this way.它应该以这种方式工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM