在ES中插入数据的ElasticSearchMap器

bkhjykvo  于 2022-11-22  发布在  ElasticSearch
关注(0)|答案(1)|浏览(142)

我正在写Map器,以便将数据插入弹性索引,但我得到了以下错误。
elasticsearch.BadRequestError:BadRequestError(400,“Map器解析异常”,“非x内容异常":只能对某些xcontent字节或压缩的xcontent字节调用压缩程序检测“)
第一个
需要创建正确的Map器以插入数据。如有任何帮助,将不胜感激。

dwbf0jvd

dwbf0jvd1#

对于Elasticsearch 8.5.0,这对我来说很有效。
Map:

{
  "mappings": {
      "properties": {
        "event_info": {
            "type": "nested",
            "properties": {
                "type_info": {"type": "text"},
                "op_type": {"type": "text"},
                "file_name": {"type": "text"},
                "file_ext": {"type": "text"},
                "process_id": {"type": "text"},
                "time_stamp": {"type": "text"}
            }
        }
     }
  }
}

要插入的文档格式:

{
  "event_info" : {
      "type_info": "INFO", 
      "op_type": "WRITE", 
      "file_name": "0.txt", 
      "file_ext": ".txt", 
      "process_id": "1234", 
      "time_stamp": "2022-10-17 05:23:06.8620427 +0000 UTC"
   }
}

如果使用bulk,您可以将文件与:

{"index": {"_index": "your_index"}}
{"event_info": {"type_info": "INFO", "op_type": "WRITE", "file_name": "0.txt","file_ext": ".txt", "process_id": "1234", "time_stamp": "2022-10-17 05:23:06.8620427 +0000 UTC"}}

相关问题