【发布时间】:2019-04-23 22:18:17
【问题描述】:
我有 4 种不同的映射:A、B、C 和 D。
对于映射A 和B,以下查询给出了最佳结果:
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"multi_match": {
"query": "....",
"analyzer": "keyword",
"fuzziness": "AUTO",
"fields": ["name*"]
}
}
]
}
}
]
}
},
"from": 0,
"size": 20
}
对于C,以下查询给出最佳结果:
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"multi_match": {
"query": "....",
"analyzer": "simple",
"fuzziness": "AUTO",
"use_dis_max": false,
"fields": ["name*"]
}
}
]
}
}
]
}
}
}
对于D,下面的查询给出了最好的结果:
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"multi_match": {
"query": "....",
"analyzer": "simple",
"fuzziness": 0,
"use_dis_max": false,
"fields": ["name*"]
}
},
{
"multi_match": {
"query": "....",
"analyzer": "simple",
"fuzziness": 3,
"fields": ["name*"]
}
}
]
}
}
]
}
}
}
我可以进行 3 个单独的查询并处理结果,但结果却很混乱并且需要更长的时间。是否可以将这 3 个查询合并为一个,并说映射/类型 A 和 B 使用第一个多重匹配 C 使用第二个,D 使用第三个。
【问题讨论】:
标签: elasticsearch elasticsearch-5 spring-data-elasticsearch