代码之家  ›  专栏  ›  技术社区  ›  famas23

[索引]中值字符串的未知键

  •  0
  • famas23  · 技术社区  · 8 年前

    我想找到一个方法来建立我的 $params 使用本机语法搜索名称等于“test”的post的数组:

    $params = [
        "index" => "post_index",
        "type" => "post",
        'body' => [
            'query' => [
                'match' => [
                    'name' => 'test'
                ]
            ]
        ]
    ];
    $result = $finder->find($params);
    

    不幸的是,我得到了这个错误:

    [索引]中值字符串的未知键。

    我知道我需要一些 Elastic\Query\Match 以生成我的查询。

    1 回复  |  直到 6 年前
        1
  •  1
  •   famas23    5 年前

    我只是这样修复了$params数组:

    $q = [
        'query' => [
            'match' => [
                'title' => 'test'
            ]
        ]
    ];