ElasticSearch 5.0 PHP msearch


(Svarup) #1

How to fire multiple queries in elasticsearch using PHP. I can't find any example of msearch in php so anyone can help me how to use msearch.


(Zachary Tong) #2

There's an msearch endpoint under the root client object:

$client->msearch([
  'body'  => [
    [
      'index' => 'indexA', 
      'type' => 'typeA'],
    [
      'query' => [
          'match_all' => (object)[],
      ],
    ],
    [
      'index' => 'indexB',
      'type' => 'typeB'
    ],
    [
      'size'  => 0,
      'query' => [
          'match_all' => (object)[],
      ],
      'aggs'  => [
          'max_sequence' => ['max' => ['field' => 'sequence']],
      ],
    ],
  ],
]);

(Svarup) #3

Thank you sir.


(Zachary Tong) #4

Happy to help! :slight_smile:


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.