Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/132408.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 132408
summary: Correct exception for missing nested path
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static <E extends Exception> Query toQuery(
if (ignoreUnmapped) {
return new MatchNoDocsQuery();
} else {
throw new IllegalStateException("[" + NAME + "] failed to find nested object under path [" + path + "]");
throw new QueryShardException(context, "[" + NAME + "] failed to find nested object under path [" + path + "]");
}
}
final BitSetProducer parentFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,7 @@ public void testIgnoreUnmapped() throws IOException {

final NestedQueryBuilder failingQueryBuilder = new NestedQueryBuilder("unmapped", new MatchAllQueryBuilder(), ScoreMode.None);
failingQueryBuilder.ignoreUnmapped(false);
IllegalStateException e = expectThrows(
IllegalStateException.class,
() -> failingQueryBuilder.toQuery(createSearchExecutionContext())
);
QueryShardException e = expectThrows(QueryShardException.class, () -> failingQueryBuilder.toQuery(createSearchExecutionContext()));
assertThat(e.getMessage(), containsString("[" + NestedQueryBuilder.NAME + "] failed to find nested object under path [unmapped]"));
}

Expand Down