Elasticsearch 5.0 Php ingest attachment


(Svarup) #1

How to force(override) ingest attachment properties.
What if I want to specify my own tittle, name, author, etc... of a document.

In mapper attachment plugin we use:

"my_attachment" : {
"_language" : "en",
"_tittle": "doc title",
"_content" : "... base64 encoded attachment ..."
}

How to do just like this in ingest attachment using php client.


(David Pilato) #2

You can use another processor in your pipeline to rename or remove fields.


(evert) #3

Nice question! I am trying to have some of these definitions as well...

Would be good if we have a sample of that, if you figure it out let us know.


(Svarup) #4

@dadoonet can you sir give me example


(evert) #5

Here is what I came up so far:

        $params = [
            'id' => 'attachment (pipeline name)',
            'body' => [
                'description' => 'Extract attachment information',
                'processors' => [
                    [
                        'attachment' => [
                            'field' => 'content',
                            'indexed_chars' => -1
                        ]
                    ],
                    [
                        'set' => [
                        'field' => 'attachment.name',
                        'value' => '{{ name }}'
                        ]
                    ],
                    [
                        'set' => [
                        'field' => 'attachment.author',
                        'value' => '{{ author }}'
                        ]
                    ],
                    [
                        'set' => [
                        'field' => 'attachment.editor',
                        'value' => '{{ editor }}'
                        ]
                    ],
                    [
                        'remove' => [
                            'field' => 'name'
                        ]
                    ],
                    [
                        'remove' => [
                            'field' => 'author'
                        ]
                    ],
                    [
                        'remove' => [
                            'field' => 'editor'
                        ]
                    ],
                ]
            ]
        ];
        return $client->ingest()->putPipeline($params);

Hope it heps!


(Svarup) #6

Thank you evert, thanks for support


(system) #7