# Getting Error on creating embedding via code

**URL:** <https://discuss.elastic.co/t/getting-error-on-creating-embedding-via-code/363530>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [July 22, 2024, 8:08am UTC](https://discuss.elastic.co/t/getting-error-on-creating-embedding-via-code/363530 "2024-07-22T08:08:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shubham\_Pandey1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shubham_pandey1/32/136199_2.png) [@Shubham\_Pandey1](https://discuss.elastic.co/u/Shubham_Pandey1)\
**Post date:** [July 22, 2024, 8:08am UTC](https://discuss.elastic.co/t/getting-error-on-creating-embedding-via-code/363530/1 "2024-07-22T08:08:46Z")

</div>

**function to create vector embeddings : -**

```auto
async getVectorEmbedding(text) {
    try {
      const response = await this.client.ingest.simulate({
        body: {
          pipeline: {
            id: process.env.INGEST_PIPELINE,
          },
          docs: [
            {
              _source: {
                combined_text: text,
              },
            },
          ],
        },
      })

      if (response.body.docs[0].error) {
        console.error('Error in processing document:', response.body.docs[0].error)
        return []
      }

      return response.body.docs[0]._source.vector_embedding
    } catch (err) {
      console.error('Failed to get vector embedding', err.meta.body)
      return []
    }
  }

```

**ingest pipeline :-**

```auto
{
  "nlp-ingest-pipeline": {
    "description": "A text embedding pipeline",
    "processors": [
      {
        "text_embedding": {
          "model_id": "model_id",
          "field_map": {
            "combined_text": "vector_embedding"
          }
        }
      }
    ]
  }
}

```

**Getting this error :-**

```auto
{
  error: {
    root_cause: [[Object] ],
    type: 'parse_exception',
    reason: '[processors] required property is missing',
    property_name: 'processors'
  },
  status: 400
}

```

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 22, 2024, 9:19am UTC](https://discuss.elastic.co/t/getting-error-on-creating-embedding-via-code/363530/2 "2024-07-22T09:19:04Z")

</div>

Hi @Shubham_Pandey1,

Welcome! Can you confirm that you are using the [Elasticsearch JavaScript client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/introduction.html)? If so, which version are you using?

I assume you are trying to trigger a pipeline you have defined in your Elasticsearch cluster? Can you try having the request options as a single level object, and `id` as a top level attribute as [per the documentation](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html):

```auto
try {
      const response = await this.client.ingest.simulate({
          id: '<my_pipeline_id>',
          docs: [
            {
              _source: {
                combined_text: text,
              }
            }
          ]
      })

```

Let us know if that solves your problem.
