# How to combine results from 2 elasticsearch indexes with different layouts

**URL:** <https://discuss.elastic.co/t/how-to-combine-results-from-2-elasticsearch-indexes-with-different-layouts/293659>\
**Category:** Elasticsearch\
**Created:** [January 6, 2022, 3:00pm UTC](https://discuss.elastic.co/t/how-to-combine-results-from-2-elasticsearch-indexes-with-different-layouts/293659 "2022-01-06T15:00:02Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 6, 2022, 5:30pm UTC](https://discuss.elastic.co/t/how-to-combine-results-from-2-elasticsearch-indexes-with-different-layouts/293659/2 "2022-01-06T17:30:20Z")

</div>

how about add alias field type to both index. It may not need reindexing.

> **[Alias field type | Elasticsearch Guide \[7.16\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/field-alias.html)**

This is an example:

```auto
PUT /my_locations1
{
  "mappings": {
    "properties": {
      "pin": {
        "properties": {
          "location": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}

PUT /my_locations1/_doc/1
{
  "pin": {
    "location": {
      "lat": 40.12,
      "lon": -71.34
    }
  }
}

PUT /my_locations2
{
  "mappings": {
    "properties": {
      "pin2": {
        "properties": {
          "location": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}

PUT /my_locations2/_doc/1
{
  "pin2": {
    "location": {
      "lat": 40.12,
      "lon": -71.34
    }
  }
}

PUT /my_locations1/_mapping
{
  "properties": {
    "location_for_search": {
      "type":"alias",
      "path": "pin.location"
    }
  }
}

PUT /my_locations2/_mapping
{
  "properties": {
    "location_for_search": {
      "type":"alias",
      "path": "pin2.location"
    }
  }
}

GET /my_locations*/_search
{
  "query":{
    "geo_distance":{
      "distance": "2000km",
      "location_for_search":{
        "lat": 40,
        "lon": -70
      }
    }
  }
}

```

```auto
{
  "took" : 9,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_locations1",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "pin" : {
            "location" : {
              "lat" : 40.12,
              "lon" : -71.34
            }
          }
        }
      },
      {
        "_index" : "my_locations2",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "pin2" : {
            "location" : {
              "lat" : 40.12,
              "lon" : -71.34
            }
          }
        }
      }
    ]
  }
}

```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-combine-results-from-2-elasticsearch-indexes-with-different-layouts/293659)._
