不太优雅的写法:

<?php
$query = [ "match_all" => new \stdClass() ];

比较优雅的写法:

<?php
$query = [ "match_all" => (object)[] ];

比较优雅的写法在IDE语法检测中是不会有额外的微警告或警告出现的。

相关参考:https://github.com/elastic/elasticsearch-php/issues/495

Related Posts: elasticsearch-php query中match_all比较优雅的写法 :

avatar