-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add Create or update query rule API call #109042
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
Add Create or update query rule API call #109042
Conversation
@@ -0,0 +1,114 @@ | |||
setup: |
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.
Note: There's not a lot of validation here. These will be fleshed out more in a followup PR when the GET
and DELETE
endpoints are implemented.
66b9b79
to
ddbad4a
Compare
Pinging @elastic/search-relevance (Team:Search - Relevance) |
Pinging @elastic/ent-search-eng (Team:SearchOrg) |
Hi @kderusso, I've created a changelog YAML for you. |
.../qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/50_query_rule_put.yml
Show resolved
Hide resolved
.../qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/50_query_rule_put.yml
Show resolved
Hide resolved
...lugin/ent-search/src/test/java/org/elasticsearch/xpack/application/rules/QueryRuleTests.java
Outdated
Show resolved
Hide resolved
.../qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/50_query_rule_put.yml
Show resolved
Hide resolved
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.
Partial review, will finish up tomorrow :)
x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRule.java
Outdated
Show resolved
Hide resolved
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.
Got a bit farther this morning, looking good!
...ch/src/main/java/org/elasticsearch/xpack/application/rules/action/PutQueryRulesetAction.java
Outdated
Show resolved
Hide resolved
...earch/src/test/java/org/elasticsearch/xpack/application/EnterpriseSearchModuleTestUtils.java
Outdated
Show resolved
Hide resolved
...rch/src/test/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexServiceTests.java
Outdated
Show resolved
Hide resolved
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 work!
...rch/src/test/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexServiceTests.java
Outdated
Show resolved
Hide resolved
...rch/src/test/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexServiceTests.java
Outdated
Show resolved
Hide resolved
.../test/java/org/elasticsearch/xpack/application/rules/action/RestPutQueryRuleActionTests.java
Outdated
Show resolved
Hide resolved
.../qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/50_query_rule_put.yml
Show resolved
Hide resolved
.../qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/50_query_rule_put.yml
Show resolved
Hide resolved
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.
LGTM, thanks for the iterations!
@@ -43,7 +43,7 @@ public TransportPutQueryRuleAction( | |||
protected void doExecute(Task task, PutQueryRuleAction.Request request, ActionListener<PutQueryRuleAction.Response> listener) { | |||
String queryRulesetId = request.queryRulesetId(); | |||
QueryRule queryRule = request.queryRule(); | |||
systemIndexService.putQueryRule(queryRulesetId, queryRule, listener.map(r -> new PutQueryRuleAction.Response(r.getResult()))); | |||
systemIndexService.putQueryRule(queryRulesetId, queryRule, ActionListener.wrap(listener::onResponse, listener::onFailure)); |
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.
Dumb question: how is this different than passing listener
directly?
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.
I had to do this because we're modifying the response from a DocWriteResponse
to PutQueryRuleAction.Response
but it's basically just wrapping it so we can change it to created for rulesets with new rules.
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.
PS there is no such thing as a dumb question 😛
Adds a new API call to create or update an individual query rule within a ruleset. If this call is made against a nonexistent ruleset the ruleset will be created.
Adds the ability to specify a priority of a query rule, which indicates the order in which it is inserted into an existing ruleset and subsequently processed.
Coming in followup PRs:
Example API call: