# Generating embeddings for arrays of objects

**URL:** <https://forum.opensearch.org/t/generating-embeddings-for-arrays-of-objects/23541>\
**Category:** OpenSearch\
**Tags:** index-management\
**Created:** [February 24, 2025, 8:42am UTC](https://forum.opensearch.org/t/generating-embeddings-for-arrays-of-objects/23541 "2025-02-24T08:42:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arun](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/arun/32/8227_2.png) [@Arun](https://forum.opensearch.org/u/Arun)\
**Post date:** [February 24, 2025, 8:42am UTC](https://forum.opensearch.org/t/generating-embeddings-for-arrays-of-objects/23541/1 "2025-02-24T08:42:40Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
opensearch 2.19

**Describe the issue** :  
i follow [this](https://opensearch.org/docs/latest/ml-commons-plugin/tutorials/generate-embeddings/) tutorial.but output result not same i get

 ![Screenshot from 2025-02-24 14-11-55](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/2/26f1cfe684bf4fe0053f221546d28eee1b747898.png)

but i got

 ![Screenshot from 2025-02-24 14-12-29](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/5/57b48579ffa7cc284af035c289ec5bb51de0b452.png)

**Configuration** :

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![nateynate](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/nateynate/32/4913_2.png) [@nateynate](https://forum.opensearch.org/u/nateynate)\
**Post date:** [February 25, 2025, 4:53pm UTC](https://forum.opensearch.org/t/generating-embeddings-for-arrays-of-objects/23541/2 "2025-02-25T16:53:39Z")

</div>

Hi @Arun!

I have to say, it’s not a lot to go on without seeing how you completed each step. Any chance you can share the mappings of your index and your payloads in creating the ingest pipeline and how you associated it with a model ID?

---

<div class="post-metadata">

**Author:** ![Arun](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/arun/32/8227_2.png) [@Arun](https://forum.opensearch.org/u/Arun)\
**Post date:** [March 4, 2025, 10:04am UTC](https://forum.opensearch.org/t/generating-embeddings-for-arrays-of-objects/23541/3 "2025-03-04T10:04:50Z")

</div>

hai @nateynate this my payloads

```auto
PUT my_books
{
  "settings" : {
      "index.knn" : "true",
      "default_pipeline": "bedrock_embedding_foreach_pipeline",
      "index.knn.space_type": "cosinesimil"
  },
  "mappings": {
    "properties": {
      "books": {
        "type": "nested",
        "properties": {
          "title_embedding": {
            "type": "knn_vector",
            "dimension": 768
          },
          "title": {
            "type": "text"
          },
          "description": {
            "type": "text"
          }
        }
      }
    }
  }
}

```

```auto
PUT _ingest/pipeline/bedrock_embedding_pipeline
{
  "processors": [
    {
      "set": {
        "field": "temp_title",
        "value": "{{ _ingest._value.title }}"
      }
    },
    {
      "text_embedding": {
        "model_id": "GsR3LZUB6qjJr3Iuo7oe",
        "field_map": {
          "temp_title": "_ingest._value.title_embedding"
        },
         "batch_size" : 200
      }
    },
    {
      "remove": {
        "field": "temp_title"
      }
    }
  ]
}

```

```auto

PUT _ingest/pipeline/bedrock_embedding_foreach_pipeline
{
  "description": "Test nested embeddings",
  "processors": [
    
    {
      "foreach": {
        "field": "books",
        "processor": {
          "pipeline": {
            "name": "bedrock_embedding_pipeline"
          }
        },
        "ignore_failure": true
      }
    }
  ]
}

```

```auto
POST _ingest/pipeline/bedrock_embedding_foreach_pipeline/_simulate
{
  "docs": [
    {
      "_index": "my_books",
      "_id": "1",
      "_source": {
        "books": [
          {
            "title": "first book",
            "description": "This is first book"
          },
          {
            "title": "second book",
            "description": "This is second book"
          }
        ]
      }
    }
  ]
}`

```

 ![Screenshot from 2025-03-04 15-33-49](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/b/b1f6fdef9e3a1e327979a5eecbda444ef323f088.png)

\_ingest.\_value.title\_embedding creating new property in top level
