Elastic のバージョン 1.6 用にビルドする場合は、会社用にクエリ ビルダーを作成し、ここで公開しました。
これをスタンドアロンのクエリ ビルダーとして使用し、最後に最終的なクエリ配列を取得してクエリ実行プログラムに渡す必要があります。
それをインストールするには、composer を使用するか、こちらcomposer require itvisionsy/php-es-orm
から圧縮バージョンをダウンロードします。
上記のリンクにはいくつかの例が含まれており、ここにコピーがあります。
//build the query using different methods
$query = \ItvisionSy\EsMapper\QueryBuilder::make()
->where('key1','some value') //term clause
->where('key2',$intValue,'>') //range clause
->where('key3','value','!=') //must_not term clause
->where('key4', ['value1','value2']) //terms clause
->where('email', '@hotmail.com', '*=') //wildcard search for all @hotmail.com emails
->sort('key1','asc') //first sort option
->sort('key2',['order'=>'asc','mode'=>'avg']) //second sort option
->from(20)->size(20) //results from 20 to 39
->toArray();
//modify the query as you need
$query['aggs']=['company'=>['terms'=>['field'=>'company']]];
//then execute it against a type query
$result = TypeQuery::query($query);
//i am not sure about Yii way to execute, according to the question, it should be:
$result = ElasticModel::find()->query($query);
このパッケージには、便利な簡単な ElasticSearch ORM クラスも含まれています。こちらをご覧ください。
これがお役に立てば幸いです...