Using multiple types or indexes in Elasticsearch php API

孤者浪人 提交于 2020-12-30 06:42:40

问题


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);

回答1:


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);


来源:https://stackoverflow.com/questions/27021693/using-multiple-types-or-indexes-in-elasticsearch-php-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!