# Using ingest pipeline attachment processor with inference processor

**URL:** <https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [July 9, 2024, 3:58am UTC](https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756 "2024-07-09T03:58:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikhatanu](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mikhatanu](https://discuss.elastic.co/u/mikhatanu)\
**Post date:** [July 9, 2024, 3:58am UTC](https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756/1 "2024-07-09T03:58:49Z")

</div>

Hello, i have a data that i would like to process through the attachment processor, then use elser inference processor to do semantic search.

I created my index with mapings:

```auto
PUT pdf
{
  "mappings": {
    "properties": {
      "nlp_enrichment": { 
        "type": "sparse_vector" 
      },
      "attachment": { 
        "type": "object" 
      }
    }
  }
}

```

Then I created the ingest pipeline:

```auto
PUT _ingest/pipeline/elser-v2-test
{
  "processors": [
    {
      "attachment": {
        "field": "data",
        "remove_binary": true
    },
      "inference": {
        "model_id": ".elser_model_2_linux-x86_64",
        "input_output": [ 
          {
            "input_field": "attachment",
            "output_field": "nlp_enrichment"
          }
        ]
      }
    }
  ]
}

```

Then i enter data:

```auto
POST pdf/_doc/1?pipeline=elser-v2-test
{
  "data":"<base64 encoded>"
}

```

But it returns error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "input field [attachment] cannot be processed because it is not a text field"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "input field [attachment] cannot be processed because it is not a text field"
  },
  "status": 400
}

```

Shouldn't the attachment processor creates processor field with object type, so the inference can get the field value of attachemnt? Or does the elser model only able to use text type?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 9, 2024, 6:27am UTC](https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756/2 "2024-07-09T06:27:07Z")

</div>

Try with:

```
"input_field": "attachment.content",

```

---

<div class="post-metadata">

**Author:** ![mikhatanu](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@mikhatanu](https://discuss.elastic.co/u/mikhatanu)\
**Post date:** [July 9, 2024, 8:26am UTC](https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756/3 "2024-07-09T08:26:01Z")

</div>

> [@dadoonet](#):
>
> `attachment`

using attachment.content works, but is it possible to inference all field in an object? I tried using foreach processor:

```auto
PUT _ingest/pipeline/elser-v2-test
{
  "processors": [
    {
      "attachment": {
        "field": "data",
        "remove_binary": true
    },
      "foreach": {
        "field": "attachment",
        "processor": {
          "inference": {
            "model_id": ".elser_model_2_linux-x86_64",
            "input_output": [ 
              {
                "input_field": "_ingest._key",
                "output_field": "nlp_enrichment._ingest._key"
              }
            ]
          }
        }
      }
    }
  ]
}

```

But it returns an object array. I've read in the documentation of inference that you can use multiple input output:

```auto
 "input_output": [ 
              {
                "input_field": "attachment.content",
                "output_field": "nlp_enrichment.content"
              },
              {
                "input_field": "attachment.content_type",
                "output_field": "nlp_enrichment.content_type"
              },
]

```

how to do this so that input\_field will use each attachment object key?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 9, 2024, 1:13pm UTC](https://discuss.elastic.co/t/using-ingest-pipeline-attachment-processor-with-inference-processor/362756/4 "2024-07-09T13:13:04Z")

</div>

I don't understand why you'd do such a thing. IMO only a small set of generated fields are eligible to run elser on.

I don't see why you would like to run elser on fields like:

```
  "content_type": "application/rtf",
  "language": "ro",
  "content_length": 28

```
