Relating two Types in ES based on common field

Hi,

We have two types on different indexes. There is a situation where we need
to query two types based on a common field.

We are looking for a single query to get the list of documents from both
the types based on the common field.

Your help will be highly appreciated.

  1. Type “location” in index “data”

POST /data/location/_mapping

{

"data": {

  "mappings": {

     "location": {

       "properties": {

           "details": {

              "type": "string"

           },

           "ids": {

              "properties": {

                 "location_id": {

                    "type": "string",

                    "index": "not_analyzed"

                 }

              }

           },

           "status": {

              "type": "string"

           }

        }

     }

  }

}

}

  1. Type “device” in index “inventory”

POST /inventory/device/_mapping

{

"inventory": {

  "mappings": {

     "device": {

       "properties": {

           "details": {

              "type": "string"

           },

           "ids": {

              "properties": {

                 "location_id": {

                    "type": "string",

                    "index": "not_analyzed"

              },

"device_id": {

   "type": "string",

                    "index": "not_analyzed"

}

              }

           },

           "status": {

              "type": "string"

           }

        }

     }

  }

}

}

The location_id is common in both the types "location" and "device" , i.e.
the value of "location_id" present in location and device are same.

Is there any single query available to get the document from location and
device types based on location_id?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/18956c1d-168d-4b88-af41-24f11543d7e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.