Skip to content

Commit

Permalink
fix default entity listing
Browse files Browse the repository at this point in the history
  • Loading branch information
david-leifker committed Nov 7, 2023
1 parent fd66bed commit dfadb92
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,23 @@ public SearchResult searchAcrossEntities(@Nonnull List<String> entities, @Nonnul
return result;
}

/**
* If no entities are provided, fallback to the list of non-empty entities
* @param inputEntities the requested entities
* @return some entities to search
*/
private List<String> getEntitiesToSearch(@Nonnull List<String> inputEntities) {
List<String> nonEmptyEntities;
List<String> lowercaseEntities = inputEntities.stream().map(String::toLowerCase).collect(Collectors.toList());
try (Timer.Context ignored = MetricUtils.timer(this.getClass(), "getNonEmptyEntities").time()) {
nonEmptyEntities = _entityDocCountCache.getNonEmptyEntities();
}
if (!inputEntities.isEmpty()) {
nonEmptyEntities = nonEmptyEntities.stream().filter(lowercaseEntities::contains).collect(Collectors.toList());

if (lowercaseEntities.isEmpty()) {
try (Timer.Context ignored = MetricUtils.timer(this.getClass(), "getNonEmptyEntities").time()) {
nonEmptyEntities = _entityDocCountCache.getNonEmptyEntities();
}
} else {
nonEmptyEntities = lowercaseEntities;
}

return nonEmptyEntities;
}

Expand Down

0 comments on commit dfadb92

Please sign in to comment.