I am using elasticsearch-1.7.3 and mapper attachment plugin-2.7.1
I have successfully add an attachment in elasticsearch with the help of php code, but while searching a text from attachment, i did not get the desired results. i get a complete attachment.
php code for adding attachment is:
$binary = fread(fopen($target_file,"r"), filesize($target_file));
$base = base64_encode($binary);
$article = array();
$article['index'] = 'test';
$article['type'] = 'person';
$article['body'] = array('my_attachment' => $base,'location2' => $location,'skills2' => $skills);
$result = $es->index($article);
where target_file is the location of file stored on my server folders, locations and skills are other fields in elasticsearch
when i search for a word in this file, i use the following php code:
$params['index'] = 'test';
$params['type'] = 'person';
$params['body']['query']['match']['my_attachment'] = $q;
$params['body']['highlight']['fields']['my_attachment'] = array("term_vector" => "with_positions_offsets","store" => true);
$query = $es->search($params);
where $q is just a text(which is there in file)
my file is a simple ms word file.
everything worked but when i echo the result it gives me complete document printed, instead of my searched text.
please if anybody can solve it or may give me a link where i can find help regarding the php code of mapper attachment(search text in a file), it would be great please reply asap