Elastic join over type in same index

I have 3 different type 'user','school','user_preferences' in one index 'elastic' .Its structure would be as follows:
User Type:
|id|name|
|1 |User A|
|2 |User B|

School Type:
|id|school_name|
|1 |School A |
|2 |School AB |
|3 |School AB |

User preferences:
|user_id|type|prefered_id|
|1 |user |2 |
|2 |school |3 |

if my user id is '1' and am searching for a school 'AB' ,then i need to get the school which my friend is preferred and then other matched schools.here user_id '2' is my friend(see user_preference type) and he preferred school 'AB'(school id 3).So in search result i need to get that school in first result and then remaining matched items.How can i achieve this using Elasticsearch?Is it possible using Elasticsearch?

  1. this is a relational database model not a NoSql document oriented model
  2. in elasticsearch 6.0, multiple types are allowed
  3. joins are not possible (unless you use parent/child feature which I don't recommend here)

With that said, just insert one single type of document which contains all the fields from your 2 tables: do join at index time.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.