我已经安装了弹性搜索,也安装在我的本地服务器上的插件。弹性发动机运转良好。我设置了以下任务:
现在我被困在寻找,它不起作用。它返回空数组。下面是我在PHP中的代码:
public function ingest_processor_searching($query)
{
$client = $this->client;
$params = [
'index' => 'ingest_index',
'type' => 'attachment',
'body' => [
'query' => [
'match' => [
'textField' => $query,
]
],
],
];
$response = $client->search($params);
return $response;
}结果:
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}但是我有GET http://localhost:9200/ingest_index/attachment/2的数据
{
"_index": "ingest_index",
"_type": "attachment",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"file_path": "/Users/selimreza/Sites/haber_dev/public/uploads/files/bower.txt",
"attachment": {
"content_type": "text/plain; charset=ISO-8859-1",
"language": "en",
"content": "Welcome to Dhaka",
"content_length": 18
},
"textField": "V2VsY29tZSB0byBEaGFrYQo="
}
}我犯了什么错?
发布于 2017-01-23 08:46:18
尝试从您的,中删除'textField' => $query,因为您不匹配多个值。如果仍然不能工作,请尝试使用术语查询而不是match
$params = [
'index' => 'ingest_index',
'type' => 'attachment',
'body' => [
'query' => [
'term' => [ <-- have this
'textField' => $query <-- try removing the comma
]
],
],
];https://stackoverflow.com/questions/41793344
复制相似问题