Filtering queries cannot have BlockJoinQuery. It would be great if they were wrapped up in a class like Elasticsearch. In elastic search is ESToParentBlockJoinQuery. You can always delete and extract the original query, but not to remove other nested query elements. You can even rebuild the wrap, automatically adding or removing nesting elements. Depending on the need.
public abstract class AbstractLuceneSearchPredicateBuilder implements SearchPredicateBuilder<LuceneSearchPredicateBuilder>,
LuceneSearchPredicateBuilder {
......
@Override
public final Query build(LuceneSearchPredicateContext context) {
.....
query = Queries.recompileToMaster(query, indexScope);
.....
The function compiles the query in one place, it would also work for LuceneSearchPredicateFactory.fromLuceneQuery. Recompiles so deeply until it encounters ESToParentBlockJoinQuery. In order not to repeat actions from previous predicates.
query = Queries.recompileToPatrial(query, nestedDocumentPath, indexScope);
Recompilation only removes ESToParentBlockJoinQuery and ToParentBlockJoinQuery associated with the path. |