首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch-PHP 7返回给定映射的所有文档

Elasticsearch-PHP 7返回给定映射的所有文档
EN

Stack Overflow用户
提问于 2021-05-22 17:27:22
回答 1查看 1.2K关注 0票数 1

摘要

未能使用ElasticSearch-PHP7包从我的ElasticSearch实例中获取任何/所有文档。

当我运行Curl查询时,工作正常。所以我知道我把文件插好了。意味着文件确实存在。

卷曲成功

Curl调用

代码语言:javascript
复制
curl -X GET -u elastic:changeme 'ltr-elasticsearch:9200/experiences_1621701804/region/_search?pretty'
代码语言:javascript
复制
{
    "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

代码语言:javascript
复制
// 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);

转储结果显示结果失败

代码语言:javascript
复制
(
    [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之外,无法升级软件包进行测试。我一有能力就会跟进。

EN

回答 1

Stack Overflow用户

发布于 2021-09-16 19:36:38

删除正文将返回所有文档

代码语言:javascript
复制
 $params = [
        'index' => 'your_index',
    ];
    $response = $this->elasticsearch->search($params);
    dump($response);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67652344

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档