# Not able to get fields from multiple source indices

**URL:** https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412
**Category:** Kibana
**Tags:** ingest-pipeline
**Created:** [October 12, 2022, 7:50am UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412 "2022-10-12T07:50:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)
#### Post date: [October 12, 2022, 7:50am UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/1 "2022-10-12T07:50:52Z")

</div>

Hi,

I gave multiple indices in the 'indices' field of the enrich policy. But it is fetching values from one index only.

Thanks

---

<div class="post-metadata">

### Author: ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)
#### Post date: [October 24, 2022, 12:16pm UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/2 "2022-10-24T12:16:48Z")

</div>

You need to provide more details to understand why your pipeline is not running. Sharing your actual pipeline would help.

I just tested a pipeline with an enrich processor defined with two indices and worked as expected. Sharing the whole test:

```auto
# Create a sample servers index and add some data
PUT /delete_enrich_servers
{
  "mappings": {
    "properties": {
      "name": { "type": "keyword"},
      "location": { "type": "keyword"},
      "brand": { "type": "keyword"}
    }
  }
}

POST delete_enrich_servers/_bulk
{ "index" : { } }
{ "name" : "s1", "location": "loc2", "brand": "b2" }
{ "index" : { } }
{ "name" : "s2", "location": "loc3", "brand": "b1" }
{ "index" : { } }
{ "name" : "s3", "location": "loc3", "brand": "b1" }
{ "index" : { } }
{ "name" : "s4", "location": "loc2", "brand": "b2" }

# Create a sample routers index and add some data
PUT /delete_enrich_routers
{
  "mappings": {
    "properties": {
      "name": { "type": "keyword"},
      "location": { "type": "keyword"},
      "brand": { "type": "keyword"}
    }
  }
}

POST delete_enrich_routers/_bulk
{ "index" : { } }
{ "name" : "r1", "location": "loc1", "brand": "b1" }
{ "index" : { } }
{ "name" : "r2", "location": "loc1", "brand": "b2" }
{ "index" : { } }
{ "name" : "r3", "location": "loc2", "brand": "b2" }
{ "index" : { } }
{ "name" : "r4", "location": "loc2", "brand": "b1" }

# Create an enrich policy to add location and brand given a name
PUT /_enrich/policy/delete-routers-servers
{
  "match": {
    "indices": ["delete_enrich_servers", "delete_enrich_routers"],
    "match_field": "name",
    "enrich_fields": ["location", "brand"]
  }
}

# Execute the policy
POST /_enrich/policy/delete-routers-servers/_execute

# Create an ingest pipeline with the enrich policy
PUT /_ingest/pipeline/delete-routers-servers-lookup
{
  "processors" : [
    {
      "enrich" : {
        "description": "Add 'location' and 'brand' data based on 'name'",
        "policy_name": "delete-routers-servers",
        "field" : "name",
        "target_field": "info",
        "max_matches": "1"
      }
    }
  ]
}

# Add a couple of documents using the pipeline
PUT delete-devices
{
  "mappings": {
    "properties": {
      "name": {"type": "keyword"}
    }
  }
}

POST delete-devices/_bulk?pipeline=delete-routers-servers-lookup
{ "index" : { } }
{ "name" : "r1" }
{ "index" : { } }
{ "name" : "s3" }

# Check the documents where enriched
GET delete-devices/_search

# Clean up
DELETE _ingest/pipeline/delete-routers-servers-lookup
DELETE _enrich/policy/delete-routers-servers
DELETE delete-devices
DELETE delete_enrich_routers
DELETE delete_enrich_servers

```

The result of `GET delete-devices/_search` shows the `info` field with the enriched data as expected.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/2/122cc8512ecb35258a12b6c9dbd593fe7326b472.png)

Hope it helps.

---

<div class="post-metadata">

### Author: ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)
#### Post date: [October 25, 2022, 11:10am UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/3 "2022-10-25T11:10:32Z")

</div>

Thanks for the response.

```auto
GET student_info/_search
 "hits" : [
      {
          "id" : "HDSJ3636",
          "name" : "Anna",
          "age" : 8
      },
      {
          "id" : "HDSJ8936",
          "name" : "Maximus",
          "age" : 7
      },
      {
          "id" : "HDSJ3674",
          "name" : "Sarah",
          "age" : 10
      }
    ]

```

* * *

```auto
GET student_marks/_search

"hits" : [
      {
          "id" : "HDSJ3636",
          "maths" : 81,
          "english" : 74,
          "science" : 89
      },
      {
          "id" : "HDSJ8936",
          "maths" : 85,
          "english" : 64,
          "science" : 69
      },
      {
          "id" : "HDSJ37895",
          "maths" : 89,
          "english" : 89,
          "science" : 89
      }
    ]

```

```auto
PUT _enrich/policy/student_details_processor
{
  "match": {
    "indices": ["student_info", "student_marks"],
    "match_field": "id",
    "enrich_fields": ["name", "maths", "science"]
  }
}

POST _enrich/policy/student_details_processor/_execute

PUT _ingest/pipeline/student_details_pipeline
{
  "processors" : [
    {
      "enrich" : {
        "description": "Add 'name' and 'stem subject marks'",
        "policy_name": "student_details_processor",
        "field" : "id",
        "target_field": "info"
      }
    }
  ]
}

```

```auto
POST student_details/_doc?pipeline=student_details_pipeline
{
  "id": "HDSJ3636",
  "gender": "Female"
}

POST student_details/_doc?pipeline=student_details_pipeline
{
  "id": "HDSJ8936",
  "gender": "Male"
}

POST student_details/_doc?pipeline=student_details_pipeline
{
  "id": "HDSJ3674",
  "gender": "Female"
}

POST student_details/_doc?pipeline=student_details_pipeline
{
  "id": "HDSJ37895",
  "gender": "Male"
}

```

```auto
GET student_details/_search

 "hits" : [
      {
          "gender" : "Female",
          "id" : "HDSJ3636",
          "info" : {
            "name" : "Anna",
            "id" : "HDSJ3636"
          }
      },
      {
          "gender" : "Male",
          "id" : "HDSJ8936",
          "info" : {
            "name" : "Maximus",
            "id" : "HDSJ8936"
          }
      },
      {
          "gender" : "Female",
          "id" : "HDSJ3674",
          "info" : {
            "name" : "Sarah",
            "id" : "HDSJ3674"
          }
      },
      {
          "gender" : "Male",
          "id" : "HDSJ37895",
          "info" : {
            "maths" : 89,
            "science" : 89,
            "id" : "HDSJ37895"
          }
      }
    ]

```

---

<div class="post-metadata">

### Author: ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)
#### Post date: [October 25, 2022, 2:02pm UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/4 "2022-10-25T14:02:27Z")

</div>

I see you want to get data from **both** indices. The enrich policy indices are meant (I suppose) to be complementary, meaning that they share a schema and your ingest documents should only get enriched by one document of any of the source indices.

For getting data from both I think that you need to set up **two different policies** , one per source index, and put them together as different processors in your pipeline.

---

<div class="post-metadata">

### Author: ![Sheereen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sheereen/32/122005_2.png) [@Sheereen](https://discuss.elastic.co/u/Sheereen)
#### Post date: [October 26, 2022, 5:22am UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/5 "2022-10-26T05:22:56Z")

</div>

Oooh..K  
What you have done is having data from both indices in your new index.... not combining data in the 2 indices.

I get it now...Thanks a lot

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 23, 2022, 5:23am UTC](https://discuss.elastic.co/t/not-able-to-get-fields-from-multiple-source-indices/316412/6 "2022-11-23T05:23:13Z")

</div>

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