How to join two index

I have two index, I want to join them both. How to do that?
for Ex: Emp is an one index with department id
Department is other index with details and index id as department id.

I want to join both index with department id

Hi spraveenjd,

Elasticsearch can not joins indices. At most you can either use parent/child or nested object mappings, but you are limited to one index only. Please refer to https://www.elastic.co/guide/en/elasticsearch/guide/2.x/relations.html for more information.

If you decide to do application side joining and you have a large dataset then you could use Apache Spark using the es-hadoop integration (https://www.elastic.co/products/hadoop).

Best regards

1 Like

Thanks Thiago
Is there a possibility to create the parent and child relation in logstash? If so please help me with a sample.

if you are talking about how to instruct logstash to create a mapping that uses parent/child, then you just need to create the appropriate index template mapping that you want to use and configure the logstash elasticsearch output to use it (refer to https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-template)

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html

instead of join ,we use terms query.

Hello QD_Wang,

Maybe you could describe a little bit more of your problem?

I don't see how terms query could be a replacement for joins...