Query data from multiple indexes


#1

Hello,
Can anyone help me that is there any possibility to query from multiple indexes,
For Example,
a. i have "index_Students" with group of students data(id,name,state,city) in it.
b. i have "index_StudentMarks" with marks of students(id,Subject1,Subject2,Subject3).

Now my question is how can i query data to get list of student marks from particular state?

Waiting for your response.

Thanks in advance


(Christian Dahlqvist) #2

Elasticsearch does not support joins, so I would recommend you denormalise your data and store student data together with the marks.


#3

thanks @Christian_Dahlqvist for the reply,
Please correct me if i am wrong,
so do i need to create a new index like "index_StudentmarksByCity" and load the data from logstash with the help of join query.

Waiting for your response
Thanks in advance.


(Jaspreet Singh) #4

Well you need a single index that stores students like this ...

{
    "name": "John Doe",
    "City":"Twiddle Dee",
    "State":"Twiddle Dum",
    "Marks": {
        "Subject1": 97,
        "Subject2": 57,
        "Subject1": 98
    }
}

Then you can query the single index.


#5

thank you @Jaspreet_Singh & @Christian_Dahlqvist i have created new index as informed