# \[PHP\] How to ingest my pdf file using PHP ES Client

**URL:** <https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622>\
**Category:** Elasticsearch\
**Created:** [November 1, 2016, 7:34pm UTC](https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622 "2016-11-01T19:34:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [November 1, 2016, 7:34pm UTC](https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622/1 "2016-11-01T19:34:01Z")

</div>

I have updated from ES 2.3 to 5, and in the docs has how to [ingest](https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.0/_indexing_documents.html) data into ES, but when using processors, with Ingest Attachment, I could not figure it out how should be done.

I have created my Pipeline with success as of below:

```
$params = [
    'id' => 'attachment',
    'body' => [
        'description' => 'Extract attachment information',
        'processors' => [
            [
                'attachment' => [
                    'field' => 'content',
                    'indexed_chars' => -1
                ]
            ]
        ]
    ]
];
return $client->ingest()->putPipeline($params);

```

I tried to index my pdf file with:

```
$params = [
    'index' => 'index',
    'type' => 'type',
    'id' => 'document_id',
    'body' => [
        'content' => base64_encode(file_get_contents($fullfile))
    ]                
];
return $client->index($params);

```

or with:

```
return $client->ingest()->putPipeline($params);

```

With no success...

Using regular json (with postman) the code below works smoothly:

```
PUT /index/type/my_indexed_id?pipeline=attachment
{
  "content" : "BuDQowMDAwNDgyMzA0I.....MY_WHOLE_ENCODED_PDF_FILE"
}

```

So, how do we inform out **$client** that we must use an specific _pipeline_?

As of used above with json: **PUT /index/type/my\_indexed\_id?pipeline=attachment**

Thanks!

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [November 2, 2016, 8:17pm UTC](https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622/2 "2016-11-02T20:17:29Z")

</div>

Note: on the run, haven't actually tried this personally yet, but you should be able to just add a 'pipeline' param to the indexing request. Set it to the pipeline's name:

```php
$params = [
    'index' => 'index',
    'type' => 'type',
    'id' => 'document_id',
    'pipeline' => 'attachment', // <----- here
    'body' => [
        'content' => base64_encode(file_get_contents($fullfile))
    ]                
];
return $client->index($params);

```

---

<div class="post-metadata">

**Author:** ![evert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/evert/32/8143_2.png) [@evert](https://discuss.elastic.co/u/evert)\
**Post date:** [November 2, 2016, 8:18pm UTC](https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622/3 "2016-11-02T20:18:14Z")

</div>

Thanks!!

---

<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:** [July 5, 2017, 10:07pm UTC](https://discuss.elastic.co/t/php-how-to-ingest-my-pdf-file-using-php-es-client/64622/4 "2017-07-05T22:07:12Z")

</div>


