Skip to content

Commit

Permalink
Improve performance for resolving derived fields (#16564) (#16566)
Browse files Browse the repository at this point in the history
Doing the type check before the string comparison makes it much faster to resolve derived fields.


(cherry picked from commit e07499a)

Signed-off-by: Robson Araujo <robson.araujo@glean.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 6557176 commit 2aa1a0a
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public Set<String> resolvePattern(String pattern) {
Set<String> derivedFields = new HashSet<>();
if (queryShardContext != null && queryShardContext.getMapperService() != null) {
for (MappedFieldType fieldType : queryShardContext.getMapperService().fieldTypes()) {
if (Regex.simpleMatch(pattern, fieldType.name()) && fieldType instanceof DerivedFieldType) {
if (fieldType instanceof DerivedFieldType && Regex.simpleMatch(pattern, fieldType.name())) {
derivedFields.add(fieldType.name());
}
}
Expand Down

0 comments on commit 2aa1a0a

Please sign in to comment.