Skip to content
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

Merged
merged 6 commits into from
Oct 26, 2022

Conversation

gabe-lyons
Copy link
Contributor

  1. removes the backwards-incompatible API change introduced in the initial advanced search pr

  2. Fixes a bug where advanced filters would not be hydrated in the case there were many facets in the result

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Oct 20, 2022
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")
Copy link
Collaborator

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);
Copy link
Collaborator

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...

Copy link
Collaborator

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

Copy link
Contributor Author

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

@github-actions
Copy link

github-actions bot commented Oct 20, 2022

Unit Test Results (build & test)

599 tests  +2   595 ✔️ +2   12m 13s ⏱️ +13s
149 suites +2       4 💤 ±0 
149 files   +2       0 ±0 

Results for commit 29c662d. ± Comparison against base commit abf1b11.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 21, 2022

Unit Test Results (metadata ingestion)

       8 files  ±0         8 suites  ±0   1h 0m 43s ⏱️ - 2m 44s
   748 tests ±0     745 ✔️ ±0  3 💤 ±0  0 ±0 
1 498 runs  ±0  1 492 ✔️ ±0  6 💤 ±0  0 ±0 

Results for commit 29c662d. ± Comparison against base commit abf1b11.

♻️ This comment has been updated with latest results.

@@ -22,5 +22,7 @@ record AggregationMetadata {
value: string
entity: optional Urn
facetCount: long
// indicates that the FilterValue is part of the search request
Copy link
Collaborator

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) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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));

Copy link
Collaborator

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()));
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@gabe-lyons gabe-lyons force-pushed the gabe--advSearchFixes branch from ed02ba5 to 1878275 Compare October 25, 2022 15:13
@gabe-lyons gabe-lyons merged commit 228c10d into datahub-project:master Oct 26, 2022
cccs-tom pushed a commit to CybercentreCanada/datahub that referenced this pull request Nov 18, 2022
* two advanced search fixes

* another approach

* adding unit tests

* fixing checkstyle issue
cccs-tom pushed a commit to CybercentreCanada/datahub that referenced this pull request Nov 18, 2022
* two advanced search fixes

* another approach

* adding unit tests

* fixing checkstyle issue
gabe-lyons added a commit to gabe-lyons/datahub that referenced this pull request Jun 13, 2023
* two advanced search fixes

* another approach

* adding unit tests

* fixing checkstyle issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants