【发布时间】:2016-06-27 15:21:25
【问题描述】:
如何在不分析数据的情况下使用不区分大小写的过滤器进行搜索? 例如在此示例中,由于大写,我将“delhi”和“Delhi”作为单独的条目。
new york 2
Delhi 1
delhi 1
new Jersey 1
预期结果:
new york 2
delhi 2
new jersey 1
我尝试了小写分析器,但为此我需要更改要分析的索引,这将返回“新”作为一个单独的城市,这是错误的。
DELETE /test_index
PUT /test_index
{
"mappings": {
"doc": {
"properties": {
"cities": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
POST /test_index/doc/_bulk
{"index":{"_id":1}}
{"cities":["new york", "delhi"]}
{"index":{"_id":2}}
{"cities":["new york", "Delhi", "new Jersey"]}
POST /test_index/_search?search_type=count
{
"aggs": {
"city_terms": {
"terms": {
"field": "cities"
}
}}}
【问题讨论】:
标签: elasticsearch