如何查找一个字段的值与另一个字段的值相匹配的所有文档

编程入门 行业动态 更新时间:2024-10-27 22:19:37
本文介绍了如何查找一个字段的值与另一个字段的值相匹配的所有文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在文档中有两个字段,具有以下映射:

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" } } ] } } } } }

更多推荐

如何查找一个字段的值与另一个字段的值相匹配的所有文档

本文发布于:2023-10-28 00:36:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1534985.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   相匹配   文档

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!