elasticsearch - Elasticsearch 动态选择查询
问题描述
使用 should 命令查询时,我想知道是否有办法只输出分数较高的查询的响应。
对不起,我英语不好,请理解。假设我有这样的数据
指数
{
"mappings": {
"properties": {
"name": {
"type": "keyword"
}
}
}
}
数据
{
"_index" : "dismisstest",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "chul"
}
},
{
"_index" : "dismisstest",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "wedul"
}
}
查询(例如..)
GET dismisstest/_search
{
"query": {
"bool": {
"should": [
{
"term": {
"name": {
"value": "wedul",
"boost": 2
}
}
},
{
"term": {
"name": {
"value": "chul",
"boost": 4
}
}
}
]
}
}
}
想要结果(仅使用 wedul 查询的文档)
{
"_index" : "dismisstest",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "wedul"
}
}
上面的查询是一个简单的例子,但我只想使用返回两个应该查询中得分高的文档的查询。有什么办法吗??
解决方案
推荐阅读
- r - 解析数字以从列中提取多个数字的平均值
- c++ - C++ 如何将不同数量的值存储到包含两个变量的结构中的变量?
- android - com.google.firebase.database.DatabaseException:无法将 java.lang.String 类型的对象转换为 models.firebase.FirebaseTripDataHolder 类型
- javascript - 我的图片没有出现,DOM 加载问题?
- artificial-intelligence - 将适者生存与遗传算法相结合?
- node.js - res.redirect 到一个后端点?
- javascript - 在 JavaScript 中组合对象数组中的 continue 值
- haskell - 非穷举模式
- firebase - 异步方法颤动后将空值获取到变量
- c# - c#中如何调用接口方法?