字段之间的elasticsearch比较

编程入门 行业动态 更新时间:2024-10-27 14:32:43
本文介绍了字段之间的elasticsearch比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我有包含以下字段的文档:{field1, field2, ... fieldn}

Let's say I have documents with the following fields: {field1, field2, ... fieldn}

我需要运行一些查询,其中某些条件需要在两个或多个字段之间进行比较.像 fieldX = fieldY

I need to run some queries where some of the conditions will require a comparison between two or more fields. like fieldX = fieldY

在标准 SQL 中,一个例子可能是:

In standard SQL, an example could be:

SELECT * FROM Table1 WHERE farePrice>100 AND originRegion = destinationRegion

我一直在阅读一些文档,看起来脚本"可能是实现这一目标的唯一方法?或者还有其他选择吗?

I'be been reading some documentation, and it looks "scripting" could be the only way to achieve this? Or are there any other options?

推荐答案

可以使用脚本过滤器 -

You can use the script filter -

{ "filtered": { "query": { "range": { "farePrice": { "gt": 100 } } }, "filter": { "script": { "script": "doc['originRegion'].value == doc['destinationRegion'].value" } } } }

您可以在 这里 和 这里.

更多推荐

字段之间的elasticsearch比较

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

发布评论

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

>www.elefans.com

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