From bb39519b5556126f0fc044fe724c463cb0d75665 Mon Sep 17 00:00:00 2001 From: Mikhail Khludnev Date: Sat, 3 Feb 2024 22:51:09 +0300 Subject: [PATCH] keep lines as they were Signed-off-by: Mikhail Khludnev --- .../org/opensearch/index/query/NestedQueryBuilder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java b/server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java index 1432d5a0f059d..3f97b3918a126 100644 --- a/server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/NestedQueryBuilder.java @@ -319,13 +319,16 @@ protected Query doToQuery(QueryShardContext context) throws IOException { } BitSetProducer previousParentFilter = context.getParentFilter(); - context.nestedScope().nextLevel(nestedObjectMapper); try { context.setParentFilter(parentFilter); - innerQuery = this.query.toQuery(context); + context.nestedScope().nextLevel(nestedObjectMapper); + try { + innerQuery = this.query.toQuery(context); + } finally { + context.nestedScope().previousLevel(); + } } finally { context.setParentFilter(previousParentFilter); - context.nestedScope().previousLevel(); } // ToParentBlockJoinQuery requires that the inner query only matches documents