问题此聚合提供所有“窗口”,但它区分大小写。如何进行不区分大小写的搜索?
GET /record_new/_search
{"size":0,
"aggs" : {
"software_tags" : {
"terms" : {
"field" : "software_tags.keyword",
"include" : ".*Windows.*",
"size" : 10000,
"order" : { "_term" : "asc" }
}
}
}
}
映射
{
"record_new": {
"mappings": {
"record_new": {
"software_tags": {
"full_name": "software_tags",
"mapping": {
"software_tags": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
},
"fielddata": true
}
}
}
}
}
}
}
响应的
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 5706542,
"max_score": 0,
"hits": []
},
"aggregations": {
"software_tags": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "Bloc-notes (Windows)",
"doc_count": 1
},
{
"key": "Windows CE",
"doc_count": 8
},
{
"key": "Windows CE 5.0",
"doc_count": 2
},
{
"key": "Windows Calculator",
"doc_count": 33
},
{
"key": "Windows Communication Foundation",
"doc_count": 43
},
{
"key": "Windows Contacts",
"doc_count": 1
},
{
"key": "Windows DVD Maker",
"doc_count": 3
},
{
"key": "Windows Defender",
"doc_count": 409
},
{
"key": "Windows Desktop Gadgets",
"doc_count": 14
},
{
"key": "Windows Desktop Update",
"doc_count": 33
},
{
"key": "Windows Display Driver Model",
"doc_count": 64
},
{
"key": "Windows DreamScene",
"doc_count": 5
},
{
"key": "Windows Driver Frameworks",
"doc_count": 1
},
{
"key": "Windows Driver Kit",
"doc_count": 12
},
{
"key": "Windows Driver Model",
"doc_count": 99
},
{
"key": "Windows Easy Transfer",
"doc_count": 3
},
{
"key": "Windows Embedded Automotive",
"doc_count": 1
},
{
"key": "Windows Embedded CE 6.0",
"doc_count": 7
},
{
"key": "Windows Embedded Compact",
"doc_count": 361
},
{
"key": "Windows Embedded Compact 7",
"doc_count": 1
},
{
"key": "Windows Embedded Industry",
"doc_count": 2
},
{
"key": "Windows Essential Business Server 2008",
"doc_count": 2
},
{
"key": "Windows Essentials",
"doc_count": 13
},
{
"key": "Windows Filtering Platform",
"doc_count": 1
},
{
"key": "Windows Firewall",
"doc_count": 588
},
{
"key": "Windows Fundamentals for Legacy PCs",
"doc_count": 21
},
{
"key": "Windows Genuine Advantage",
"doc_count": 60
},
{
"key": "Windows Home Server",
"doc_count": 7
},
{
"key": "Windows Image Acquisition",
"doc_count": 1
},
{
"key": "Windows Insider",
"doc_count": 10
},
{
"key": "Windows Installer",
"doc_count": 562
},
{
"key": "Windows Internal Database",
"doc_count": 2
},
{
"key": "Windows IoT",
"doc_count": 132
},
{
"key": "Windows Live Mail",
"doc_count": 117
},
{
"key": "Windows Live Mesh",
"doc_count": 1
},
{
"key": "Windows Live Messenger",
"doc_count": 1595
},
{
"key": "Windows Live OneCare",
"doc_count": 18
},
{
"key": "Windows Live OneCare Safety Scanner",
"doc_count": 1
},
{
"key": "Windows Live Spaces",
"doc_count": 1
},
{
"key": "Windows Live Toolbar",
"doc_count": 4
},
{
"key": "Windows ME",
"doc_count": 1055
},
{
"key": "Windows Management Instrumentation",
"doc_count": 289
},
{
"key": "Windows Marketplace",
"doc_count": 4
},
{
"key": "Windows Media",
"doc_count": 168
},
{
"key": "Windows Mobile",
"doc_count": 439
},
{
"key": "Windows SideShow",
"doc_count": 1
},
{
"key": "Windows SteadyState",
"doc_count": 6
},
{
"key": "Центр обновления Windows",
"doc_count": 2
}
]
}
}
}
答案 0 :(得分:1)
我认为你完全错了。搜索和获取唯一值是不同的事情。以下方法怎么样?
请注意,我对聚合使用了稍微不同的设置,我添加了query
。
GET record_new/_search
{
"size": 0,
"query": {
"term": {
"software_tags": {
"value": "windows"
}
}
},
"aggs": {
"software_tags": {
"terms": {
"field": "software_tags.keyword",
"include" : ".*Windows.*",
"size": 10000,
"order": {
"_count": "desc"
}
}
}
}
}