概括
无法使用 ElasticSearch-PHP 7 包从我的 ElasticSearch 实例中获取任何/所有文档。
当我运行 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
我目前正在使用弹性搜索/弹性搜索的 v 5.2。
看起来 v5 不支持 match_all?这对我来说真的很奇怪。我认为一个基本功能是获取所有文档。我知道它是一个搜索工具,也许它只是专注于过滤的搜索结果。并且它可能只是以未记录的不同方式处理它。
v5:https ://www.elastic.co/guide/en/elasticsearch/client/php-api/5.x/_match_query.html
我目前被锁定在我的工作 VPN 之外,无法升级软件包进行测试。一旦我有能力就会跟进。