我正在撰寫用于將資料插入彈性索引的映射器,但出現以下錯誤。
elasticsearch.BadRequestError: BadRequestError(400, 'mapper_parsing_exception', 'not_x_content_exception: Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes')
mapper = {"mappings":
{
"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"}
}
}
}
}
data = [{'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'}]}]
需要為插入資料創建正確的映射器。任何幫助,將不勝感激。
uj5u.com熱心網友回復:
使用 Elasticsearch 8.5.0,這對我有用。
映射:
{
"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"
}
}
如果使用批量,您可以將檔案與:
{"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"}}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/533380.html
標籤:Python弹性搜索
