I have installed elasticsearch in my local pc. Also installed mapper-attachments and kibana.
I can index string data into a index and search. But when I trying to search text from PDF or docx in a folder :: Its not working. Its returning null or blank array().
I searched on google and read the elastic documentation but Still I have nothing to resolve it. Would you guide me ? Here is my code ::
$client = \Elasticsearch\ClientBuilder::create()->build();
$doc_src = public_path()."/uploads/files/bower.pdf";
$binary = fread(fopen($doc_src, "r"), filesize($doc_src));
$doc_str = base64_encode($binary);
$data_string = 'Welcome to Dhaka! Anwar is a gentleman!';
//index data and assign by index "my_index"
$params = [
'index' => 'my_index',
'type' => 'attachment',
'id' => 'my_id',
'body' => [
'testField' => $data_string,
'fileName' => $doc_src,
'file' => $doc_str
]
];
$response = $client->index($params);
#print_r($response);
//search data from the index "my_index"
$params = [
'index' => 'my_index',
'type' => 'attachment',
'body' => [
'query' => [
'match' => [
#'testField' => 'dhaka',
'file' => 'dhaka'
]
],
]
];
$response = $client->search($params);
print_r($response['hits']['hits']);
Bottom points :
1. when I tried to teach using `testField` from the `data_string` then its working nicely.
2. When I tried to search from pdf file `doc_str` `=>` Its not working
I think I missed something big. Any helps is highly appreciated!