搜索在ElasticSearch中的Ingest Processor中无法正常工作
这是映射代码
public function ingest_processor_mapping()
{
$client = \Elasticsearch\ClientBuilder::create()->build();
$params = [
'id' => 'attachment',
'body' => [
'description' => 'Extract attachment information',
'processors' => [
[
'attachment' => [
'field' => 'content',
'indexed_chars' => -1
]
]
]
],
];
return $client->ingest()->putPipeline($params);
}
结果 ::
{
"acknowledged": true
}
这是我在PHP中的索引代码
public function ingest_processor_indexing()
{
$client = \Elasticsearch\ClientBuilder::create()->build();
$fullfile = public_path().'/uploads/files/bower.pdf';
$params = [
'index' => 'ingest_index',
'type' => 'attachment',
'id' => 'document_id',
'pipeline' => 'attachment', // <----- here
'body' => [
'content' => base64_encode(file_get_contents($fullfile)),
'file_path' =>$fullfile,
]
];
return $client->index($params);
}
结果::
{
"_index": "ingest_index",
"_type": "attachment",
"_id": "document_id",
"_version": 2,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": false
}
这是我在PHP中搜索CODE ::
public function ingest_processor_searching()
{
$client = \Elasticsearch\ClientBuilder::create()->build();
$params = [
'index' => 'ingest_index',
'type' => 'attachment',
'body' => [
'query' => [
'match' => [
'content' => 'dhaka'
]
],
]
];
$response = $client->search($params);
print_r($response['hits']['hits']);
}
结果::
Array( )
道歉,我搞砸了什么。你能帮助我,让每个人都能得到最好的答案吗?