# Using reindex to generate embeddings from nested field

**URL:** <https://discuss.elastic.co/t/using-reindex-to-generate-embeddings-from-nested-field/373957>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning, ingest-pipeline\
**Created:** [January 31, 2025, 4:27pm UTC](https://discuss.elastic.co/t/using-reindex-to-generate-embeddings-from-nested-field/373957 "2025-01-31T16:27:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Fernando\_Palm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_fernando_palm/32/77804_2.png) [@Carlos\_Fernando\_Palm](https://discuss.elastic.co/u/Carlos_Fernando_Palm)\
**Post date:** [January 31, 2025, 4:27pm UTC](https://discuss.elastic.co/t/using-reindex-to-generate-embeddings-from-nested-field/373957/1 "2025-01-31T16:27:59Z")

</div>

Hello! I was reading this:

> **[Tutorial: semantic search with ELSER | Elasticsearch Guide \[8.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-search-elser.html)**

And I tried to apply the idea of using a reindex command together with an ingest pipeline to generate the embeddings of data already inside an elastic index.

Now I defined the ingest pipeline like this:

```auto
PUT _ingest/pipeline/elser-v2-test
{
  "processors": [
    {
      "inference": {
        "model_id": ".elser_model_2_linux-x86_64",
        "input_output": [ 
          {
            "input_field": "field1.field2.field3",
            "output_field": "headline_embedding"
          }
        ]
      }
    }
  ]
}

```

And then I run something like this:

```auto
POST _reindex?wait_for_completion=false
{
  "source": {
    "index": "initial_index",
    "size": 50 
  },
  "dest": {
    "index": "index_with_embeddings",
    "pipeline": "elser-v2-test"
  }
}

```

but when I run this command:

```auto
GET _tasks/OofTXXZuTgaA1afd0zXhRA:15419763

```

I see these exceptions

"cause": {  
"type": "illegal\_argument\_exception",  
"reason": "[field3] is not an integer, cannot be used as an index as part of path [field1.field2.field3]"  
},

The documentation example uses a non-nested field in the transformation. Is it possible to do the same with nested fields?

---

<div class="post-metadata">

**Author:** ![iulia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iulia/32/124658_2.png) [@iulia](https://discuss.elastic.co/u/iulia)\
**Post date:** [February 3, 2025, 10:03am UTC](https://discuss.elastic.co/t/using-reindex-to-generate-embeddings-from-nested-field/373957/2 "2025-02-03T10:03:41Z")

</div>

Hi!

I've just tried to replicate this with some nested field and using the `input_output` field I get the same error indeed.

What did work, is switching to the `field_mapping` alternative which helps ELSER figure out how to reach the specific field you want (basically telling it that the address of your nested field is what it should take as the usually named `text_field` input).

```auto
PUT _ingest/pipeline/elser-v2-test-nest
{
  "processors": [
    {
      "inference": {
        "model_id": ".elser_model_2",
        "target_field": "content_embedding",
        "field_map": {
          "nested_content.nested_field.extra_nest": "text_field"
          }
        }
    }
  ]
}

```

You can see more info about this [method in the docs.](https://www.elastic.co/guide/en/elasticsearch/reference/8.17/infer-service-elser.html)

Let me know if setting up like this works with your nested example!  
hope it helps.

Kind regards,  
Iulia
