- Notifications
You must be signed in to change notification settings - Fork 25.7k
ES|QL - Allow full text functions to be used in STATS ... WHERE #125479
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
Changes from all commits
5f4eff5 748e576 dc1dbe6 3117d50 3a753d2 2a8e987 c99d373 2cc6898 425f146 c842f14 8a0f48f dfce035 3963fd3 85a2374 4f3228a 351d1ff 52dd7b9 02f8748 f9bf170 e98ad43 40eaeb8 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| pr: 125479 | ||
| summary: ES|QL - Allow full text functions to be used in STATS | ||
| area: ES|QL | ||
| type: enhancement | ||
| issues: | ||
| - 125481 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -750,3 +750,94 @@ book_no:keyword | |
| 7140 | ||
| 2714 | ||
| ; | ||
| | ||
| testMatchInStatsNonPushable | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| | ||
| from books | ||
| | where length(title) > 40 | ||
| | stats c = count(*) where match(title, "Lord") | ||
| Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here are some suggestions on the test coverages that I can think of, these also apply to the other full text functions and operators:
Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I added testing in 3963fd3, hopefully that works!
It affects scoring as well. I'm thinking that is the same as so using a FTF in a STATS WHERE clause affects scoring as well. I think it's better for consistency, but happy to discuss with the team. Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The example above makes sense to me. I wonder how the Member Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@fang-xing-esql good catch. That doesn't work, as the filters are not pushed down to Lucene and thus there's no scoring available 😓 It could be doable to calculate the scoring on the individual WHERE clauses in the aggregation, but I'm inclined not to do it. We're looking into having separate scores for individual queries as a separate effort, and this kind of replicates some of those efforts. What I've done is to disallow the usage of but does not allow to use WHERE in STATS: Change done in e98ad43 I think this is a good compromise, and we can work to lift that limitation later if needed be. LMKWYT | ||
| ; | ||
| | ||
| c:long | ||
| 3 | ||
| ; | ||
| | ||
| testMatchInStatsPushableAndNonPushable | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| | ||
| from books | ||
| | stats c = count(*) where (match(title, "lord") and ratings > 4.5) or (match(author, "dostoevsky") and length(title) > 50) | ||
| ; | ||
| | ||
| c:long | ||
| 6 | ||
| ; | ||
| | ||
| testMatchInStatsPushable | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| | ||
| from books | ||
| | stats c = count(*) where match(author, "tolkien") | ||
| ; | ||
| | ||
| c:long | ||
| 22 | ||
| ; | ||
| | ||
| testMatchInStatsWithOptions | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| | ||
| FROM books | ||
| | STATS c = count(*) where match(title, "Hobbit Back Again", {"operator": "AND"}) | ||
| ; | ||
| | ||
| c:long | ||
| 1 | ||
| ; | ||
| | ||
| testMatchInStatsWithNonPushableDisjunctions | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| | ||
| FROM books | ||
| | STATS c = count(*) where match(title, "lord") or length(title) > 130 | ||
| ; | ||
| | ||
| c:long | ||
| 5 | ||
| ; | ||
| | ||
| testMatchInStatsWithMultipleAggs | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| FROM books | ||
| | STATS c = count(*) where match(title, "lord"), m = max(book_no::integer) where match(author, "tolkien"), n = min(book_no::integer) where match(author, "dostoevsky") | ||
| ; | ||
| | ||
| c:long | m:integer | n:integer | ||
| 4 | 9607 | 1211 | ||
| ; | ||
| | ||
| | ||
| testMatchInStatsWithGrouping | ||
| required_capability: match_function | ||
| required_capability: full_text_functions_in_stats_where | ||
| FROM books | ||
| | STATS r = AVG(ratings) where match(title, "Lord Rings", {"operator": "AND"}) by author | WHERE r is not null | ||
| ; | ||
| ignoreOrder: true | ||
| | ||
| r:double | author: text | ||
| 4.75 | Alan Lee | ||
| 4.674999952316284 | J. R. R. Tolkien | ||
| 4.670000076293945 | John Ronald Reuel Tolkien | ||
| 4.670000076293945 | Agnes Perkins | ||
| 4.670000076293945 | Charles Adolph Huttar | ||
| 4.670000076293945 | Walter Scheps | ||
| 4.559999942779541 | J.R.R. Tolkien | ||
| ; | ||
Uh oh!
There was an error while loading. Please reload this page.