[英]Elasticsearch-PHP 7 Return All documents of a given mapping
Failing to get any/all documents from my ElasticSearch instance using the ElasticSearch-PHP 7 package.无法使用 ElasticSearch-PHP 7 package 从我的 ElasticSearch 实例获取任何/所有文档。
When I run Curl query, works just fine.当我运行 Curl 查询时,工作得很好。 So I know I have bulk inserted the documents properly.所以我知道我已经正确地批量插入了文档。 Meaning that documents do exist.意味着文件确实存在。
Curl Call 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
]
}
};
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/search_operations.html 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
(
)
)
)
Rookie move, I should have compared versions.菜鸟之举,我应该对比一下版本。 There is a version mapping for the package elasticsearch/elasticsearch. package elasticsearch/elasticsearch 有一个版本映射。
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/installation.html https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/installation.html
I am currently on v 5.2 of elasticsearch/elasticsearch.我目前正在使用弹性搜索/弹性搜索的 v 5.2。
It looks like v5 does not support match_all?看起来 v5 不支持 match_all? Which to me is really odd.这对我来说真的很奇怪。 I would think a fundamental feature would be to get ALL documents.我认为一个基本功能是获取所有文档。 I get it's a search tool, and maybe it just focused on filtered search results.我知道它是一个搜索工具,也许它只是专注于过滤的搜索结果。 And it's possible it just handles it in a different way undocumented.并且它可能只是以未记录的不同方式处理它。
v5: https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.x/_match_query.html v5: https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.x/_match_query.html
I am currently locked out of my work VPN and unable to upgrade packages to test.我目前被锁定在我的工作 VPN 之外,无法升级软件包进行测试。 Will follow up once I am able.一旦我有能力就会跟进。
remove body will return all document删除正文将返回所有文档
$params = [
'index' => 'your_index',
];
$response = $this->elasticsearch->search($params);
dump($response);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.