HOW-TO: terms lookup or sth-else


(Nikos Skalis) #1

hi guys,

i am looking to cross-check two elastic search indices by comparing at least two keys
the question is how can i query two indices and apply filtering on them ?
for example

if i have an index called index_1 with mapping

{a1:"a1", b1:5, c1:"c"}

also, i have another index_2 with different mapping

{a2:"a2", b2:8, c2:"c"}

and i would like to retrieve the set of documents that

  • c1 equals to c2
  • b2 > b1

could you please advise on how this can be accomplished ?


(Ivan Brusic) #2

You cannot apply a join between two indices. You cannot even join two
documents inside the same index without using parent/child relationships.

Ivan


(Nikos Skalis) #3

thanks Ivan.
https://github.com/elastic/elasticsearch/issues/2674 with terms lookup you can filter based on a value of a key that belongs to a different document of a different index, correct ?


(Ivan Brusic) #4

The terms filter will not quite fulfill your requirements since your are
looking to match on more than one field, plus you would need to provide an
id for the document in the other index. You cannot match on arbitrary
documents. Do you want to result to be both documents?

Ivan


(system) #5