TLDR:即使映射显示为not_analyzed,也会分析某些字段。
我有几组数据,每组数据都是根据数据集中包含的日期发送到Elasticsearch索引的(它给出了类似index-25012016的索引名称)。一些集合具有相同的日期,因此具有相同的索引。
我使用以下perl命令将映射发送到ESprint `curl -s -XPUT "http://$ELASTIC_SEARCH_URL/$currentIndexName?pretty" -d ' $mapping'`
其中$ currentIndexName和$ mapping是分别看起来像index-25012016
和
{
"mappings": {
"myMappingType": {
"properties": {
"present": {
"type":"boolean"
},
"records": {
"type":"integer"
},
"batchID": {
"type":"string",
"index":"not_analyzed"
},
"version": {
"type":"string",
"index":"not_analyzed"
},
"date": {
"type":"date",
"format":"yyyy-MM-dd"
},
"packageCreationDate": {
"type":"date",
"format":"MM/dd/yyyy-HH:mm"
}
}
}
}
}
还有更多 Realm 。
除了我之前已经完成的任何$ currentIndexName之外,所有集都将重复执行此命令。
运行该命令时,来自ES的答案是
{
"acknowledged" : true
}
无论是跳过还是完成了此映射步骤,然后我都使用
`curl -s -XPOST "$ELASTIC_SEARCH_URL/$currentIndexName/_bulk?pretty" --data-binary \@$outputFileName`;
将数据发送到ES其中$ outputFileName是json文件的名称。
问题是,即使我指定not_analyzed,在Kibana / Settings / Indices中,字符串字段也被标记为分析和索引,而我只想在其中索引。因此,例如,由于所有版本字段都是相同的(“3.2.506 64位”),饼图将显示三个相等的“3.2.506”,“64”和“位”片,而不是整个未 slice 的“3.2.506 64位”饼图。但是,不分析 bool(boolean) 值,数字,日期字段和元字段。
Kibana中的索引模式匹配所有这些索引(index- *),并将日期用作基于时间的事件字段。
发送数据后,我尝试重新创建索引模式,它没有任何改变。
我在Windows 7上,不使用Logstash。
编辑:由于此刻我进行了大量测试,因此每次脚本启动时,我都会先删除数据,然后再使用
print `curl -s -XDELETE "http://localhost:9200/index-*?pretty`;
因此,脚本如下所示:Remove data
for each set in allSets
mapping (if not already mapped in a previous iteration)
send data to ES
最佳答案
现有数据的映射无法更新。您需要使用正确的映射创建一个新索引,然后将文档重新索引到该索引中。这是ES文档的链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#_updating_existing_mappings
您还可以使用索引模板将映射自动应用于新创建的索引:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html
关于perl - 映射中的not_analyzed被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38846191/