0

Two indices documents as below:

class First(Document):

    class Index:
       name  = 'first'
       
   case_id = Keyword()
   name = Text()
   
class Second(Document):

    class Index:
       name  = 'second'
       
   case_id = Keyword()
   status = Text()

I just want to execute a query like below in SQL format

select * from first as f, second as s where s.case_id = f.case_id or s.status = 'xyz'

How can I do it using elastic search dsl query?

1 Answer 1

1
  1. Elastic Search doesn't support joins between indexes

    Reason: Elastic Search is not relational and denormalized data should be stored here.

    Excerpt from elastic Doc below :

Performing full SQL-style joins in a distributed system like Elasticsearch is prohibitively expensive. Instead, Elasticsearch offers two forms of join which are designed to scale horizontally.

  1. Use either nesting or parent/child mapping to store your data, based on the use case.

    Nesting: If cardinality of nested doc is very low and indexes are read intensive

    Parent/child: If cardinality of child is very high than parent and parent/child needs to be updated frequently

Sign up to request clarification or add additional context in comments.

1 Comment

Or third option: simply denormalize your data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.