-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add a query rules tester API call #114168
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 a query rules tester API call #114168
Conversation
c73a6bf
to
3613634
Compare
3613634
to
df6dfa8
Compare
Pinging @elastic/search-eng (Team:SearchOrg) |
Pinging @elastic/search-relevance (Team:Search - Relevance) |
Hi @kderusso, I've created a changelog YAML for you. |
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
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/70_query_rule_test.yml
Show resolved
Hide resolved
@Override | ||
protected void doExecute(Task task, TestQueryRulesetAction.Request request, ActionListener<TestQueryRulesetAction.Response> listener) { | ||
GetQueryRulesetAction.Request getQueryRulesetRequest = new GetQueryRulesetAction.Request(request.rulesetId()); | ||
originSettingClient.execute(GetQueryRulesetAction.INSTANCE, getQueryRulesetRequest, new ActionListener<>() { |
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.
If we ever want to open this API to not require the manage_search_query_rules
privilege like we discussed, if changing this similarly to #105667 to use executeAsyncWithOrigin
would be the solution
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.
Thanks, I will look into that!
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.
Believe it or not, that doesn't work either!
I updated the call to use executeAsyncWithOrigin
and I still get yaml tests failing with the following error:
- type: "security_exception"
reason: "action [indices:data/read/xpack/query_rules/test] is unauthorized for\
\ user [entsearch-admin] with effective roles [admin] on restricted indices\
\ [.query-rules], this action is granted by the index privileges [read,all]"
I am stumped why this doesn't work, as it definitely does when we use the rule query. I'm inclined to punt and figure it out later before we GA the call, just to get something out there. That would require us keeping the manage query rules privilege for now. What are your thoughts?
|
||
- do: | ||
catch: forbidden | ||
headers: { Authorization: "Basic ZW50c2VhcmNoLXVzZXI6ZW50c2VhcmNoLXVzZXItcGFzc3dvcmQ=" } # user |
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.
Is this checking that we are requiring the manage_search_query_rules
privilege?
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.
Correct, that's the permission we're using right now.
include::put-query-rule.asciidoc[] | ||
include::get-query-rule.asciidoc[] | ||
include::delete-query-rule.asciidoc[] | ||
include::test-query-ruleset.asciidoc[] |
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 other docs/guides where we want to refer to this API as a way to test/troubleshoot a query rules set? (can be done as a follow up)
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'd like to do that as a followup. This is being launched in preview right now, because there may be evolving requirements. I think when it gets closer to beta or GA is when it would be most helpful to promote this more, WDYT?
private final int totalMatchedRules; | ||
private final List<MatchedRule> matchedRules; | ||
|
||
private static final ParseField TOTAL_MATCHED_RULES_FIELD = new ParseField("total_matched_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.
Why do we need a total_matched_rules
in the response? could we just return the matched_rules
? just trying to understand
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.
We could just return the matched rules. I was thinking it could be convenient in the event there were 1000 rules returned, or we want to provide pagination in the future.
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.
++ for keeping total_matched_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.
Looks good overall, great job 🙌 ! I only have minor comments.
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/70_query_rule_test.yml
Outdated
Show resolved
Hide resolved
...n/ent-search/src/main/java/org/elasticsearch/xpack/application/EnterpriseSearchFeatures.java
Outdated
Show resolved
Hide resolved
...qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/rules/70_query_rule_test.yml
Show resolved
Hide resolved
private final int totalMatchedRules; | ||
private final List<MatchedRule> matchedRules; | ||
|
||
private static final ParseField TOTAL_MATCHED_RULES_FIELD = new ParseField("total_matched_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.
++ for keeping total_matched_rules
...h/src/main/java/org/elasticsearch/xpack/application/rules/action/TestQueryRulesetAction.java
Show resolved
Hide resolved
...csearch/xpack/application/rules/action/TestQueryRulesetActionRequestBWCSerializingTests.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.
LGTM, thanks for the changes!
💚 Backport successful
|
* Add a query rules tester API call * Update docs/changelog/114168.yaml * Wrap client call in async with origin * Remove unused param * PR feedback * Remove redundant test * CI workaround - add ent-search as ml dependency so it can find node features
* Add a query rules tester API call * Update docs/changelog/114168.yaml * Wrap client call in async with origin * Remove unused param * PR feedback * Remove redundant test * CI workaround - add ent-search as ml dependency so it can find node features
* Add a query rules tester API call * Update docs/changelog/114168.yaml * Wrap client call in async with origin * Remove unused param * PR feedback * Remove redundant test * CI workaround - add ent-search as ml dependency so it can find node features
* Add a query rules tester API call * Update docs/changelog/114168.yaml * Wrap client call in async with origin * Remove unused param * PR feedback * Remove redundant test * CI workaround - add ent-search as ml dependency so it can find node features
* Add a query rules tester API call * Update docs/changelog/114168.yaml * Wrap client call in async with origin * Remove unused param * PR feedback * Remove redundant test * CI workaround - add ent-search as ml dependency so it can find node features
Adds a tester call to the query ruleset API.
Example call:
Example response: