![](/img/trans.png)
[英]How to find all documents where the value of one field matches that of another
[英]Find documents where all array field values matches predicate
給定以下文檔架構
{
"type": ["A", "B"]
}
其中field type是關鍵字類型的索引字段。
我想查找所有類型為 field的值都應匹配謂詞p的文檔。
基本上我需要檢查類型字段中的所有值是否在另一個數組中。 例如,上面的[“ A”,“ B”,“ C]文檔匹配,而[[A],” D“]則不匹配。
您可以使用scripts
來解決此問題。 這里的想法是檢查doc
所有元素是否都存在於input_array
。 參考: 子集討論
在6.3版中,通過terms_set
查詢對此提供了本機支持。 參考: terms-set-query-dsl
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.