Hi,
Facing problem to index a pdf document using elasticsearch Ingest plugin.
I have done the following,
-
Created the pipline -
PUT _ingest/pipeline/attachment
{
"description" : "Extract attachment information",
"processors" : [
{
"attachment" : {
"field" : "data"
}
}
]
} -
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');
- 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