摘要
未能使用ElasticSearch-PHP7包从我的ElasticSearch实例中获取任何/所有文档。
当我运行Curl查询时,工作正常。所以我知道我把文件插好了。意味着文件确实存在。
卷曲成功
Curl调用
curl -X GET -u elastic:changeme 'ltr-elasticsearch:9200/experiences_1621701804/region/_search?pretty'{
"took": 58,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 100,
"max_score": 1,
"hits": [
{
"_index": "experiences_1621701804",
"_type": "region",
"_id": "14",
"_score": 1,
"_source": {
"id": 14,
"name": "Dallas",
"active": "1",
"image": {
"domain": null,
"original": "https://d2l34t1fl9ccx8.cloudfront.net/media/image/d/a/dallas.jpg",
"small": "https://d2l34t1fl9ccx8.cloudfront.net/media/image/d/a/dallas.jpg",
"thumbnail": "https://d2l34t1fl9ccx8.cloudfront.net/media/image/d/a/dallas.jpg"
}
}
}
// many more document results show up here
]
}
};Elasticsearch-PHP 7搜索手册
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/search_operations.html
// Build Params with Raw JSON
$params = [
'index' => 'experiences_1621701804',
'type' => 'region',
'body' => '{
"query": {
"match_all": {}
}
}',
];
// Also tried
$params = [
'index' => 'experiences_1621701804',
'type' => 'region',
'body' => [
'query' => [
'match_all' => new \stdClass()
]
]
];
// Trigger Search
$results = $esClientBuilder->search($params);
print_r($results);转储结果显示结果失败
(
[took] => 0
[timed_out] =>
[_shards] => Array
(
[total] => 5
[successful] => 5
[skipped] => 0
[failed] => 0
)
[hits] => Array
(
[total] => 0
[max_score] =>
[hits] => Array
(
)
)
)更新了可能的解决方案?
菜鸟的动作,我应该比较一下版本。对于elasticsearch/elasticsearch包有一个版本映射。
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/installation.html
我目前在elasticsearch/elasticsearch的第5.2版。
看起来v5不支持match_all吗?对我来说真的很奇怪。我认为一个基本的特点是获得所有的文件。我知道这是一个搜索工具,也许它只是专注于过滤的搜索结果。而且有可能它只是以一种不同的方式处理它,没有文件记录。
v5:https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.x/_match_query.html
我目前被排除在我的工作VPN之外,无法升级软件包进行测试。我一有能力就会跟进。
发布于 2021-09-16 19:36:38
删除正文将返回所有文档
$params = [
'index' => 'your_index',
];
$response = $this->elasticsearch->search($params);
dump($response);https://stackoverflow.com/questions/67652344
复制相似问题