ElasticSearch 5.0 PHP msearch

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.

1 Like

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']],
      ],
    ],
  ],
]);
5 Likes

Thank you sir.

Happy to help! :slight_smile:

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