Skip to content

Commit f689409

Browse files
committed
catch uoe
1 parent c2ca74b commit f689409

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

server/src/main/java/org/opensearch/index/mapper/DerivedFieldType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public Query geoShapeQuery(Geometry shape, String fieldName, ShapeRelation relat
477477

478478
@Override
479479
public Query existsQuery(QueryShardContext context) {
480-
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] does not support exist queries");
480+
throw new UnsupportedOperationException("Field [" + name() + "] of type [" + typeName() + "] does not support exist queries");
481481
}
482482

483483
@Override

server/src/main/java/org/opensearch/index/query/ExistsQueryBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private static Query newObjectFieldExistsQuery(QueryShardContext context, String
205205
try {
206206
Query existsQuery = context.getMapperService().fieldType(field).existsQuery(context);
207207
booleanQuery.add(existsQuery, Occur.SHOULD);
208-
} catch (Exception e) {
208+
} catch (UnsupportedOperationException e) {
209209
// ignore some subfields which not support exists query
210210
// if none of the subfields support the exists query, this is equivalent to MatchNoDocsQuery
211211
}

server/src/test/java/org/opensearch/index/query/ExistsQueryBuilderTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void testFromJson() throws IOException {
176176
public void testObjectFieldWithDerivedSubField() throws IOException {
177177
QueryShardContext shardContext = createShardContext();
178178
final ExistsQueryBuilder queryBuilder1 = new ExistsQueryBuilder("raw.derived_keyword");
179-
expectThrows(IllegalArgumentException.class, () -> queryBuilder1.toQuery(shardContext));
179+
expectThrows(UnsupportedOperationException.class, () -> queryBuilder1.toQuery(shardContext));
180180
final ExistsQueryBuilder queryBuilder2 = new ExistsQueryBuilder("raw");
181181
Query actual = queryBuilder2.toQuery(shardContext);
182182
Query expected = new ConstantScoreQuery(

0 commit comments

Comments
 (0)