-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(adv search): two advanced search fixes #6252
fix(adv search): two advanced search fixes #6252
Conversation
Value of the field to filter by. Deprecated in favor of `values`, which should accept a single element array for a | ||
value | ||
""" | ||
value: String @deprecated(reason: "Prefer `values` for single elements") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -488,7 +490,7 @@ private void addMissingAggregationValueToAggregationMetadata(@Nonnull final Stri | |||
|| originalMetadata.getFilterValues().stream().noneMatch(entry -> entry.getValue().equals(value)) | |||
) { | |||
// No aggregation found for filtered value -- inject one! | |||
originalMetadata.getAggregations().put(value, 0L); | |||
originalMetadata.getAggregations().put(value, MAX_VALUE_FOR_FILTER_VALUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the implication of this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This basically makes it so that if the user tries to filter on something that does not exist, we report it correctly to them on the product side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that filters in the query will have priority over aggregations added just because they appear in search results
@@ -22,5 +22,7 @@ record AggregationMetadata { | |||
value: string | |||
entity: optional Urn | |||
facetCount: long | |||
// indicates that the FilterValue is part of the search request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly i very much dislike the entire FilterValue struct that has been just tossed in here (much earlier). But this feels like a useful way to capture that context, and even return it to the client if need be
* @param aggregations the aggregations coming back from elasticsearch combined with the filters from the search request | ||
* @param filteredValues the set of values provided by the search request | ||
*/ | ||
public static List<FilterValue> convertToFilters(Map<String, Long> aggregations, Set<String> filteredValues) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Do we have any unit tests for this SearchUtil test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -136,10 +137,16 @@ public static AggregationMetadata merge(AggregationMetadata one, AggregationMeta | |||
Map<String, Long> mergedMap = | |||
Stream.concat(one.getAggregations().entrySet().stream(), two.getAggregations().entrySet().stream()) | |||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, Long::sum)); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any unit tests for this static class? If not we should at least log some backlog ticket about the coverage here.
@@ -135,15 +135,25 @@ public static Filter buildFilter(@Nullable List<FacetFilterInput> andFilters, @N | |||
public static Criterion criterionFromFilter(final FacetFilterInput filter) { | |||
Criterion result = new Criterion(); | |||
result.setField(getFilterField(filter.getField())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have tests for this method elsewhere? It will be good to test the new changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
ed02ba5
to
1878275
Compare
* two advanced search fixes * another approach * adding unit tests * fixing checkstyle issue
* two advanced search fixes * another approach * adding unit tests * fixing checkstyle issue
* two advanced search fixes * another approach * adding unit tests * fixing checkstyle issue
removes the backwards-incompatible API change introduced in the initial advanced search pr
Fixes a bug where advanced filters would not be hydrated in the case there were many facets in the result
Checklist