-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Package version
v4.5.1
Describe the bug
When using queryNested or whereNested and then adding a grouped query like such:
$query->where(function (Builder $subQuery) {
$subQuery->whereNull('somefield')
->orWhere('somefield', '=', 'something');
});the resulting elastic DSL fails with the following error:
400 Bad Request: [1:52] [bool] unknown field [test.must] - [1:52] [bool] unknown field [test.must]
To Reproduce
<?php
use PDPhilip\Elasticsearch\Eloquent\Model;
use PDPhilip\Elasticsearch\Query\Builder;
use PDPhilip\Elasticsearch\Schema\IndexBlueprint;
use PDPhilip\Elasticsearch\Schema\Schema;
class Test extends Model
{
protected $guarded = [];
protected $index = 'test_index';
public $connection = 'elasticsearch';
}
Schema::deleteIfExists('test_index');
Schema::create('test_index', function (IndexBlueprint $index) {
$index->nested('test');
});
Test::create([
'test' => [
[
'somefield' => null,
],
[
'somefield' => 'something',
]
]
]);
$query = Test::queryNested('test', function (Builder $query) {
$query->where(function (Builder $subQuery) {
$subQuery->whereNull('somefield')
->orWhere('somefield', '=', 'something');
});
});
dump($query->toDsl());
dd($query->get());Expected behavior
Ability to use nested queries in combination with grouped queries, allowing for true grouped queries in nested queries or wheres
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working