Elasticsearch - attachment using Ingest - with node.js

Hi,
Facing problem to index a pdf document using elasticsearch Ingest plugin.

I have done the following,

  1. Created the pipline -
    PUT _ingest/pipeline/attachment
    {
    "description" : "Extract attachment information",
    "processors" : [
    {
    "attachment" : {
    "field" : "data"
    }
    }
    ]
    }

  2. Created my index reading pdf file and inserted in to the created pipeline.

function indexfile(tUrl)
{
return new Promise(function (resolve, reject) {
request(tUrl, function(error, response, body){
if(!error){
let arr = new Buffer(body, 'binary').toString('base64');
insertDocIngest(base64.encode(arr));
}else{
console.log(body);
reject(error);
}
});
});
}

function insertDocIngest(fileData){
esClient.index({index:'repo_index', type:'rec_type', id:'13', pipeline:'attachment',
body:{
"data": fileData
}
})
.then(response => {
console.log('Successfully created the index');
})
.catch(error => {
console.log(error.message);
});
}

indexfile('http://www.cbu.edu.zm/downloads/pdf-sample.pdf');

  1. It can create the index successfully, but while I ty to search the document, as
    function search(query, index_val){
    return esClient.search({
    q: query,
    index: index_val
    }).catch(error => {
    console.log(error.message);
    });
    }

function test()
{
let index = 'repo_index';
let query = 'always';
search(query, index)
.then(results => {
console.log(found ${results.hits.total} items in ${results.took}ms);
})
.catch(console.error);
}

test();

I am not able to find the document.

I know I am missing something, could anyone help me in this?

Thanks in advance,
Anjan

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

What does a document that you indexed is looking like?
I mean if you do a GET indexname/typename/id?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.