可以在Query DSL上比较不同类型的两个字段吗? [英] Is it possible to compare two fields from different types on a Query DSL?

查看:898
本文介绍了可以在Query DSL上比较不同类型的两个字段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ElasticSearch的新手,我正在努力解决这个问题。基本上我想做的是这样的(SQL示例):

I'm new to ElasticSearch and I'm struggling with this question. Basically what I want to do is sort of like this (SQL Example):

SELECT A.id
FROM TableA A, TableB B
WHERE A.id = B.id;

我想要一个从TableA返回所有信息的查询,但只有当TableA的ID为等于TableB的id。
我已经读了很多查询过滤器字段,我想我可以使用术语字段,但我不知道如何。

I want a Query that returns all of the info from TableA, but only if the id from TableA is equal to an id from TableB. I've read a lot of Query Filter fields and I think I might use the Term Field but I'm not sure how.

提前感谢

推荐答案

此答案由Adrien Grand on a ElasticSearch组:

This answer was given by Adrien Grand on a ElasticSearch group:


此SQL查询是一个连接,一般来说,elasticsearch不支持连接。

This SQL query is a join and in general elasticsearch does not support joins.

如果id字段是您的PK,您可以通过将B作为A的子代(使用父/子)进行索引,然后在A中搜索有孩子的所有文档B。

If the id field is your PK, you might be able to do it by indexing B as a child of A (using parent/child) and then searching for all documents in A that have a child in B.

这篇关于可以在Query DSL上比较不同类型的两个字段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆