Skip to content

Commit e07499a

Browse files
authored
Improve performance for resolving derived fields (opensearch-project#16564)
Doing the type check before the string comparison makes it much faster to resolve derived fields. Signed-off-by: Robson Araujo <robson.araujo@glean.com>
1 parent b25e10a commit e07499a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public Set<String> resolvePattern(String pattern) {
7272
Set<String> derivedFields = new HashSet<>();
7373
if (queryShardContext != null && queryShardContext.getMapperService() != null) {
7474
for (MappedFieldType fieldType : queryShardContext.getMapperService().fieldTypes()) {
75-
if (Regex.simpleMatch(pattern, fieldType.name()) && fieldType instanceof DerivedFieldType) {
75+
if (fieldType instanceof DerivedFieldType && Regex.simpleMatch(pattern, fieldType.name())) {
7676
derivedFields.add(fieldType.name());
7777
}
7878
}

0 commit comments

Comments
 (0)