【问题标题】:Using multiple types or indexes in Elasticsearch php API在 Elasticsearch php API 中使用多种类型或索引
【发布时间】:2015-01-17 06:10:42
【问题描述】:

我想使用 Elasticsearch PHP API 查询多种类型和索引。但我不知道怎么做。 我应该将类型和索引数组传递给 $params 吗? :

$params['index'] = $index;//array of indices
$params['type']  = $types;//array of types
$params['body']  = $q;//query body
//request elasticsearch for matched documents
$results = $client->search($params);

【问题讨论】:

    标签: php api search types elasticsearch


    【解决方案1】:

    您只需将它们作为 字符串 添加到 $params

    $params['index'] = "index1,index2";// a comma-separated list of index names, without any extra space
    $params['type']  = "type1, type2";//array of types
    $params['body']  = $q;//query body
    //request elasticsearch for matched documents
    $results = $client->search($params);
    

    【讨论】:

    • 我知道这是旧的,但我刚刚遇到的问题是......索引值中的逗号后没有空格非常重要!它只会崩溃。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-28
    相关资源
    最近更新 更多