Closed ankr closed 7 years ago
I believe the failing tests were already failing befor this PR.
I think the method you are looking for is compileQuery()
@lorenzo In my specific case I would like to get it before it's compiled. I'm passing the returned value to Cake\ElasticSearch\Query::setFullQuery()
after wrapping it in a HasParent
query.
you can get the compiled one, wrap it and set it again
You are right @lorenzo. Must have done something else wrong previously.
Actually no, this isn't going to work. If I use the result from compileQuery
in a hasParent
my filters will be applied to parent documents, and not my current Type
.
public function findFoo(Query $query, array $options)
{
$query = $query->where(['foo' => 'bar']);
$builder = new QueryBuilder();
$parent = $builder->hasParent($query->compileQuery()->toArray(), 'user');
return $query->setFullQuery($parent);
}
In the above case the ['foo' => 'bar']
condition will be applied to the parent user
documents.
@ankr a problem with this PR is that the _elasticaQuery
object is empty until you call compileQuery
Gonna close this PR as I managed to resolve my issue without this method. I still think it could could be useful being able to access the Elastica query without compiling it. But let's burn that bridge when we get to it.
Possible to get a hold on the elastica query object without compiling it.