Is your feature request related to a problem? Please describe.
Problem: cannot use range condition through ->where() in scout query builder. And any other conditions except equation (ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery)
It is expected that query should look like this:
Ad::search($request->keywords)
->when($request->minPrice || $request->maxPrice, function (ScoutBuilder $query) use ($request) {
$params = [];
if ($request->minPrice) {
$params[RangeQuery::GTE] = $request->minPrice;
}
if ($request->maxPrice) {
$params[RangeQuery::LTE] = $request->maxPrice;
}
$priceRange = new RangeQuery('price', $params);
$query->where('price', $priceRange);
});
Describe the solution you'd like
There is an interface ONGR\ElasticsearchDSL\BuilderInterface which is used to implement conditions like ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery and ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery so we can use instances of these classes as a value for ->where() query when we need something special.
Describe alternatives you've considered
Currently to solve this task we need to use callback passed to Model::search() and do some magic which looks like overkill and also it is very complex.
Additional context
I've already tested the solution and will submit PR. It is actually very simple.
Is your feature request related to a problem? Please describe. Problem: cannot use range condition through
->where()
in scout query builder. And any other conditions except equation (ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery
)It is expected that query should look like this:
Describe the solution you'd like There is an interface
ONGR\ElasticsearchDSL\BuilderInterface
which is used to implement conditions likeONGR\ElasticsearchDSL\Query\TermLevel\TermQuery
andONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery
so we can use instances of these classes as a value for->where()
query when we need something special.Describe alternatives you've considered Currently to solve this task we need to use callback passed to
Model::search()
and do some magic which looks like overkill and also it is very complex.Additional context I've already tested the solution and will submit PR. It is actually very simple.