Pull data from multiple index

I am having 2 index as follows, this is a sample index. My request is to get Employees from employee-details-v1 index whose course is dotnet. Need to get this in single ES Query not in 2 steps

It's a sample index. Same need to be applied to my prod data. Is there is any way to achieve this without changing the index structure.


{
        "_index": "employee-courses-v2",
        "_id": "3",
        "_score": 0.4700036,
        "_source": {
          "empid": 3,
          "courses": [
            "python",
            "dotnet"
          ]
        }
      }

{
        "_index": "employee-details-v1",
        "_id": "2",
        "_score": 1,
        "_source": {
          "empid": 2,
          "namefirst": "Matthew",
          "namelast": "Baren"
        }
      }

Hello and welcome,

What you want to do is a join, this is not supported in Elasticsearch, you need to normalize your data or do multiple queries and join the results in your code.

There is not, if you want to get information from both employee-courses index and employee-details you will need to change your index and normalize your data.

For example, you would need to add the information from employee-details into the employee-courses.

Your document would be something like this:

{
  "empid": 3,
  "courses": [
    "python",
    "dotnet"
  ],
  "namefirst": "first name of empid 3",
  "namelast": "last name of empid 3",
}