在 Elasticsearch php API 中使用多种类型或索引 [英] Using multiple types or indexes in Elasticsearch php API
本文介绍了在 Elasticsearch php API 中使用多种类型或索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 Elasticsearch PHP API 查询多种类型和索引.但我不知道如何.我应该将一组类型和索引传递给 $params
吗?:
I want to query multiple types and indices using Elasticsearch PHP API. but I don't Know how.
should I pass an array of types and indices to $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);
推荐答案
您只需将它们作为 string 添加到 $params
:
You just add them as a string to $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);
这篇关于在 Elasticsearch php API 中使用多种类型或索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文