java - 如何在 Elastic Search 中从多个查询(查询 1 中的 x 记录和查询 2 中的 y 记录)中获取有限的结果
问题描述
我有两个不同的查询,我想从它们中得到一个组合结果,即来自查询 1 的 x 条记录和来自查询 2 的 y 条记录。我该怎么做?
目前我正在使用以下查询:
**{ "bool" : {
"should" : [
{
"multi_match" : {
"query" : "indea",
"fields" : [
"admin^1.0",
"city^1.0",
"country^1.0"
],
"type" : "best_fields",
"operator" : "OR",
"slop" : 0,
"fuzziness" : "2",
"prefix_length" : 0,
"max_expansions" : 50,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
},
{
"multi_match" : {
"query" : "Maharashtra",
"fields" : [
"admin^1.0"
],
"type" : "best_fields",
"operator" : "OR",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"zero_terms_query" : "NONE",
"auto_generate_synonyms_phrase_query" : true,
"fuzzy_transpositions" : true,
"boost" : 1.0
}
}
],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}**
解决方案
推荐阅读
- javascript - 在 Javascript 中生成 HMAC 与在 python 中生成的 HMAC 不匹配(使用 utf-8 编码字符)
- php - php if else条件在变量中作为字符串
- reactjs - 带有 next.js 的动态标头
- java - 试图理解 Liskov 替换原理
- php - Stripe 客户门户 PHP 实施 - 将客户重定向到 URL
- assembly - 为什么“推送”会在这里导致段错误?
- excel - 等待 OLE 操作 - 自动“单击”好吗?
- sql - 如何从一组有序的行中完全选择下一行和上一行?
- c++ - if 语句或比较 C++
- networking - Openstack:如何给管理网络Internet?