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

[Connector API] Change UpdateConnectorFiltering API to have better defaults #108612

Conversation

efegurkan
Copy link
Member

This changes validation behaviour for rules to have better defaults instead of throwing. The following cases changed to not throw:

  • When "rules" is an empty array, instead of throwing we attach a default rule
  • When "rules" have items but doesn't have default rule, we append a default rule.
  • Rules array will be ordered and default will be moved as the last

@efegurkan efegurkan added :EnterpriseSearch/Application Enterprise Search Team:Enterprise Search Meta label for Enterprise Search team v8.15.0 labels May 14, 2024
@efegurkan efegurkan requested a review from jedrazb May 14, 2024 11:58
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ent-search-eng (Team:Enterprise Search)

@efegurkan efegurkan force-pushed the update-connector-filtering-api-for-better-defaults branch from c7845b0 to 39dbd9a Compare May 14, 2024 13:23
Copy link
Member

@jedrazb jedrazb left a comment

Choose a reason for hiding this comment

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

LGTM! Great to see more folks contributing to ES! I left some nit comments about adding more tests, comments and minor refactoring

.findFirst();

List<FilteringRule> sortedRules = rules.stream()
.filter(rule -> rule.equalsExceptForTimestampsAndOrder(getDefaultFilteringRule(null, 0)) == false)
Copy link
Member

Choose a reason for hiding this comment

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

maybe let's create another method isDefaultFilteringRule, it might be confusing why we do this:

rule.equalsExceptForTimestampsAndOrder(getDefaultFilteringRule(null, 0))

@@ -196,9 +196,22 @@ private static FilteringValidation getRandomFilteringValidationError() {
.build();
}

public static FilteringRule getDefaultFilteringRule(Instant currentTimestamp, Integer order) {
Copy link
Member

Choose a reason for hiding this comment

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

This is accessed from within non test code, so maybe let's move it to ConnetorFiltering.java file?

Also we call it a lot with getDefaultFilteringRule(null, 0) so we can use method overloading or add WithOrder explicitly at the end of the method name:

public static FilteringRule getDefaultFilteringRuleWithOrder(Integer order) {
   getDefaultFilteringRule(null, order)
}

@elasticsearchmachine
Copy link
Collaborator

Hi @efegurkan, I've created a changelog YAML for you.

This changes validation behaviour for rules to have better defaults
instead of throwing. The following cases changed to not throw:

- When "rules" is an empty array, instead of throwing we attach a
  default rule
- When "rules" have items but doesn't have default rule, we append a
  default rule.
- Rules array will be ordered and default will be moved as the last
@efegurkan efegurkan force-pushed the update-connector-filtering-api-for-better-defaults branch from c33e50a to 0dcdccb Compare May 15, 2024 11:20
@elasticsearchmachine
Copy link
Collaborator

Hi @efegurkan, I've created a changelog YAML for you.

@efegurkan efegurkan requested a review from jedrazb May 15, 2024 12:02
Copy link
Member

@jedrazb jedrazb left a comment

Choose a reason for hiding this comment

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

LGMT! Thank you for looking into this

@efegurkan efegurkan merged commit b83d09c into elastic:main May 16, 2024
15 checks passed
nicktindall pushed a commit to nicktindall/elasticsearch that referenced this pull request May 17, 2024
…faults (elastic#108612)

* Change UpdateConnectorFiltering API to have better defaults

This changes validation behaviour for rules to have better defaults
instead of throwing. The following cases changed to not throw:

- When "rules" is an empty array, instead of throwing we attach a
  default rule
- When "rules" have items but doesn't have default rule, we append a
  default rule.
- Rules array will be ordered and default will be moved as the last

* Update docs/changelog/108612.yaml
parkertimmins pushed a commit to parkertimmins/elasticsearch that referenced this pull request May 17, 2024
…faults (elastic#108612)

* Change UpdateConnectorFiltering API to have better defaults

This changes validation behaviour for rules to have better defaults
instead of throwing. The following cases changed to not throw:

- When "rules" is an empty array, instead of throwing we attach a
  default rule
- When "rules" have items but doesn't have default rule, we append a
  default rule.
- Rules array will be ordered and default will be moved as the last

* Update docs/changelog/108612.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :EnterpriseSearch/Application Enterprise Search Team:Enterprise Search Meta label for Enterprise Search team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants