Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Bodybuilder | 1,218 | 105 | 58 | a month ago | 65 | May 21, 2022 | 9 | mit | JavaScript | |
An elasticsearch query body builder :muscle: | ||||||||||
Elastic Builder | 460 | 16 | 16 | 17 days ago | 58 | June 05, 2021 | 16 | mit | JavaScript | |
A Node.js implementation of the elasticsearch Query DSL :construction_worker: | ||||||||||
Esquery | 222 | a year ago | 7 | apache-2.0 | Go | |||||
An idiomatic Go query builder for ElasticSearch | ||||||||||
Elasticshell | 106 | 8 years ago | 13 | apache-2.0 | Java | |||||
A javascript shell for elasticsearch | ||||||||||
Elasticquery | 78 | 2 years ago | 53 | December 15, 2021 | 3 | mit | Python | |||
A simple (Python) query builder for Elasticsearch | ||||||||||
Wpes Lib | 67 | 3 years ago | gpl-2.0 | PHP | ||||||
WordPress-Elasticsearch Lib | ||||||||||
Q Builders | 48 | 4 | 2 | 2 years ago | 7 | June 23, 2017 | 2 | mit | Java | |
Type safe database agnostic query builders. | ||||||||||
Fast Elasticsearch Query Builder | 47 | 4 years ago | apache-2.0 | Java | ||||||
A fast way to build ElasticSearch query string, even without writing implement code. | ||||||||||
Spring Data Elasticsearch | 47 | 7 years ago | 2 | HTML | ||||||
:cn:Spring-Data-Elasticsearch官方文档的中文翻译版本,翻译不好请见谅,欢迎提issue | ||||||||||
Elasticsearch Query Builder | 37 | 2 months ago | 2 | mit | PHP | |||||
Build query for an ElasticSearch client using a fluent interface |
Query DSL Builder for Elasticsearch queries
Use ElasticBuilder to combine multiple queries/filters/aggregations into Elasticsearch Query DSL within Laravel projects!
ElasticBuilder is released under the MIT Open Source License, https://opensource.org/licenses/MIT
ElasticBuilder © Broker Exchange Network 2018
ElasticBuilder is a Laravel 5.x Framework Package consisting of Static Methods and Abstract classes you can use to build Elasticsearch query DSL AND map your query input arguments to the DSL as it is generated. Also handles paging arguments, sorting, and aggregations. Provides Laravel Framework Service Provider and Facade, as well as a Trait you can apply to your eloquent models.
ElasticBuilder must use Elasticsearch 1.x or greater, and Laravel 5.x
"brokerexchange/elasticbuilder": "^1.0.0"
to your composer.json
filecomposer update
ElasticBuilder\ElasticBuilderServiceProvider::class
to your list of providers in app/config/app.php
of your laravel project'Eb' => ElasticBuilder\Eb::class
to your list of aliases in app/config/app.php
of your laravel projectExample of using a Facade
Here is how you add a clause to a query (in this case must clause to bool query).
<?php
$query = Eb::boolean()
->must(Eb::term('category_id',1))
->filter(Eb::range('published_at',['lte' => Carbon::now()->toIso8601String(),'gte' => Carbon::now()->subDay(10)->toIso8601String()]));
var_dump($query);
<?php
$query = \Eb::multi_match(['title^3','summary^1','body','userName^2','categoryName^2','tag_string^1'],'lorim ipsum','and','cross_fields');
var_dump($query);
Apply the trait class to an eloquent model (possibly one already using Elasticquent/Elasticquent or similar package)
<?php
use ElasticBuilder\ElasticBuilderTrait;
/**
* Class Article
* @package App
*/
class Article extends Model
{
use ElasticBuilderTrait;
Now you can use a static bool,dismax,boosting etc query from within a model simlilar to the eloquent query builder!
<?php
Article::bool()->filter(Eb::term('category_id','1);
or
<?php
Article::dis_max()->query(Eb::match('body',$keywords));
Bool query with aggregation as eloquent model trait
<?php
//trait example
$results = $article->boolean()
->must(Eb::match('body','keyword search string'))
->aggregate(Eb::agg()->terms('categories','category_id'))->get(); //returns Elasticquent Results Object
var_dump($results);
//trait exaple with paging
$results = $article->boolean()
->must(Eb::match('body','keyword search string'))
->aggregate(Eb::agg()->terms('categories','category_id'))->paginate(20); //returns Elasticquent Paginator Object
var_dump($results);
<?php
if($this->request->has('search')){
$search = $this->request->get('search');
$match = \Eb::multi_match(['title^3','summary^1','body','userName^2','categoryName^2','tag_string^1'],$search,'and','cross_fields');
} else {
$match = \Eb::match_all();
}
$this->must($match);
Here is an example of adding a filter to the bool query from within the extended class
<?php
$filter = \Eb::range('published_at',['lte' => Carbon::now()->toIso8601String()]);
$this->filter($filter);
More Examples
<?php
$query = Article::agg()
->terms('categories','category_id');
var_dump($query);