问题
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;
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.
Thanks in advance!
回答1:
This answer was given by Adrien Grand on a ElasticSearch group:
This SQL query is a join and in general elasticsearch does not support joins.
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.
来源:https://stackoverflow.com/questions/29799207/is-it-possible-to-compare-two-fields-from-different-types-on-a-query-dsl