我用这两个查询进行测试
用 must 查询
{
"size": 200,
"from": 0,
"query": {
"bool": {
"must": [ {
"match": {
"_all": "science"
}
},
{
"match": {
"category": "fiction"
}
},
{
"match": {
"country": "us"
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
}
使用 should + minimum_should_match 查询
{
"size": 200,
"from": 0,
"query": {
"bool": {
"should": [ {
"match": {
"_all": "science"
}
},
{
"match": {
"category": "fiction"
}
},
{
"match": {
"country": "us"
}
}
],
minimum_should_match: 3 …Run Code Online (Sandbox Code Playgroud) 我想从汽车中获得不同的 make 值,并且 make 值应该按升序排序,不区分大小写。我正在使用弹性搜索版本 2.4.4
颜色和制作字段的映射
"color": {
"type": "string",
"fields": {
"keyword": {
"type": "string",
"index": "not_analyzed"
},
"lcsort": {
"type": "string",
"analyzer": "case_insensitive_sort"
}
}
},
"make": {
"type": "string",
"fields": {
"keyword": {
"type": "string",
"index": "not_analyzed"
},
"lcsort": {
"type": "string",
"analyzer": "case_insensitive_sort"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在 case_insensitive_sort 分析器上的设置
"analysis": {
"analyzer": {
"case_insensitive_sort": {
"filter": [
"lowercase"
],
"tokenizer": "keyword"
}
}
}
Run Code Online (Sandbox Code Playgroud)
查询 1
{
"size" : 0,
"query" : {
"bool" : …Run Code Online (Sandbox Code Playgroud)