Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using multiple types or indexes in Elasticsearch php API

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);
like image 645
Ramin Omrani Avatar asked Nov 19 '14 16:11

Ramin Omrani


1 Answers

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);
like image 155
Ramin Omrani Avatar answered Oct 16 '22 01:10

Ramin Omrani