考虑到下面的文档Map,如何筛选 source-string
包含至少2个相同 targetStrings.score
价值观?
PUT /source-string
{
"mappings": {
"properties": {
"id": { "type": "keyword" },
"targetStrings": {
"type": "nested",
"properties": {
"id": { "type": "keyword" },
"score": { "type": "integer" }
}
}
}
}
}
带1的索引示例 source-string
其中包含 targetStrings
有两个相同的 score
第1页。我想把这个还给你。
"_index" : "source-string",
"_type" : "_doc",
"_id" : "VHS796CQKuFZo2GPmb1T",
"_source" : {
"id" : "VHS796CQKuFZo2GPmb1T",
"targetStrings" : [
{
"score" : 1,
"id" : "id1"
},
{
"score" : 2,
"id" : "id2"
},
{
"score" : 1,
"id" : "id3"
}
]
}
}
1条答案
按热度按时间rbl8hiat1#
你可以用
min_doc_count
使用术语聚合,它将返回匹配超过配置的命中数的术语添加索引数据、搜索查询和搜索结果的工作示例
索引数据:
搜索查询:
搜索结果:
更新1:
如果只想检索那些具有完全相同的2个分数的文档,可以使用bucket选择器聚合