本文介绍了如何查找一个字段的值与另一个字段的值相匹配的所有文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在文档中有两个字段,具有以下映射:
I have two fields within a document with the following mapping:
"field_a": { "type": "float" }, "field_b": { "type": "float" }如何查找 field_a 的值与 field_b ?这是可能的脚本禁用?
How can I find all documents where the value for field_a matches that of field_b? Is this possible with scripting disabled?
推荐答案基本上你需要一个脚本来做 - 即使脚本被禁用,这可能会工作因为lucene表达式是完全沙盒的:
Basically you need a script to do it -- this may work even if scripting is disabled because the lucene expressions are fully sandboxed:
GET /index/_search { "query": { "filtered": { "query": { "match_all": {} }, "filter": { "bool": { "must": [ { "script": { "lang": "expression", "script": "doc['field_a'].value == doc['field_b'].value" } } ] } } } } }更多推荐
如何查找一个字段的值与另一个字段的值相匹配的所有文档
发布评论