我正在尝试将一些这样的消息推送到 elasticsearch
id=1
list=asd,bcv mnmn,kjkj, pop asd dgf
因此,每条消息都有id
一个字符串字段和一个list
包含字符串值列表的字段
当我将它推入弹性并尝试在 kibana 中创建图表时,默认分析器会启动并按list
空格字符分割我的。因此,它打破了我的价值观。我试图为我的索引创建一个映射
mapping='''
{
"test":
{
"properties": {
"DocumentID": {
"type": "string"
},
"Tags":{
"type" : "string",
"index" : "not_analyzed"
}
}
}
}'''
es = Elasticsearch([{'host': server, 'port': port}])
indexName = "testindex"
es.indices.create(index=indexName, body=mapping)
所以这应该使用我定义的映射创建索引。现在,我通过简单的方式推送消息
es.index(indexName, docType, messageBody)
但即使是现在,Kibana 也打破了我的价值观!为什么没有应用映射?
当我这样做的时候
GET /testindex/_mapping/test
我明白了
{
"testindex": {
"mappings": {
"test": {
"properties": {
"DocumentID": {
"type": "string"
},
"Tags": {
"type": "string"
}
}
}
}
}
}
为什么映射发生了变化?当我这样做时如何指定映射类型
es.index()