我試圖推某些消息像這樣elasticsearchElasticsearch:es.index()改變時消息被推映射
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()
感謝很多:) – AbtPst
很高興我能幫助:) – ChintanShah25