-
Couldn't load subscription status.
- Fork 25.6k
retain the scores of portions of an ES|QL query, via a score function #127551
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 84 commits
77101fc
819b364
e2f774d
457aebe
494f95e
8f38eb3
701fe46
0ed4f70
bab8a4b
9e78a73
ddb40cd
d1e2f1a
5ba09df
ec3b05a
59ec292
d0c17a4
b8001af
d6b2649
6944207
880ec89
994c9de
522bdfb
e8229e1
2edaef8
a15844d
f0d3b76
eac33c1
bb78db6
68023d8
2200e15
2e0c9d6
d43d52e
14d763b
77f41ae
6356809
7e67a7b
d4c2392
fa34213
e2ac064
0ccc315
1c0b575
52f8b3e
cce6f98
51c5427
4237ac7
80cf204
bb60241
28568a4
9e01d7b
141ec72
ac3b001
5ed05c9
31db011
36959c8
979c615
e125cbe
62817f4
df01c8a
ee51465
25e9d4c
df3f8ac
0c46574
28848db
e19ea6b
177b9f3
1bec8d6
45e96bb
d91cf10
d121042
6060f84
10edc05
0d7ecd1
afc1287
f0cd402
eb14196
b964313
f4dfa0a
88997d9
97822b3
86287a9
852fb22
c941ea7
e888da2
398aa7c
18df6f0
87bce59
c0e6258
c852c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| ############################################### | ||
| # Tests for Score function | ||
| # | ||
|
|
||
| scoreSingle | ||
| required_capability: metadata_score | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| // tag::score-function[] | ||
| FROM books METADATA _score | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL first_score = score(match(title, "Return")) | ||
| // end::score-function[] | ||
| | KEEP book_no, title, _score, first_score | ||
| | SORT book_no | ||
| | LIMIT 5 | ||
| ; | ||
|
|
||
| // tag::score-single-result[] | ||
| book_no:keyword | title:text | _score:double | first_score:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 3.1309072971343994 | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 4.8434343338012695 | 3.5432329177856445 | ||
| // end::score-single-result[] | ||
| ; | ||
|
|
||
| scoreSingleNoMetadata | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| FROM books | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL first_score = score(match(title, "Return")) | ||
| | KEEP book_no, title, first_score | ||
| | SORT book_no | ||
| | LIMIT 5 | ||
| ; | ||
|
|
||
| book_no:keyword | title:text | first_score:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 3.5432329177856445 | ||
| ; | ||
|
|
||
| scoreAfterEval | ||
| required_capability: score_function | ||
| required_capability: metadata_score | ||
| required_capability: match_function | ||
|
|
||
| FROM books METADATA _score | ||
| | EVAL stars = to_long(ratings / 2.0) | ||
| | EVAL s1 = score(match(author, "William")) | ||
| | WHERE match(author, "Faulkner") | ||
| | SORT book_no | ||
| | KEEP book_no, author, stars, s1 | ||
| | limit 5; | ||
|
|
||
| book_no:keyword | author:text | stars:long | s1:double | ||
| 2378 | [Carol Faulkner, Holly Byers Ochoa, Lucretia Mott] | 3 | 0.0 | ||
| 2713 | William Faulkner | 2 | 1.9043500423431396 | ||
| 2847 | Colleen Faulkner | 3 | 0.0 | ||
| 2883 | William Faulkner | 2 | 1.9043500423431396 | ||
| 3293 | Danny Faulkner | 2 | 0.0 | ||
| ; | ||
|
|
||
| scoreMatchWithFilterConjunction | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| FROM books | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL s1 = score(match(title, "Rings") and ratings > 4.6) | ||
| | KEEP book_no, title, s1 | ||
| | SORT book_no | ||
| | LIMIT 5; | ||
|
|
||
| book_no:keyword | title:text | s1:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 0.0 | ||
| ; | ||
|
|
||
| scoreMatchWithDisjunction | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| FROM books | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL s1 = score(match(title, "Rings") or match(title, "Shadow")) | ||
| | KEEP book_no, title, s1 | ||
| | SORT book_no | ||
| | LIMIT 5; | ||
|
|
||
| book_no:keyword | title:text | s1:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 3.5432329177856445 | ||
| ; | ||
|
|
||
| scoreMatchWithDisjunctionAndFilter | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| FROM books | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL s1 = score(match(title, "Rings") or match(title, "Shadow") and ratings > 4.6) | ||
| | KEEP book_no, title, s1 | ||
| | SORT book_no | ||
| | LIMIT 5; | ||
|
|
||
| book_no:keyword | title:text | s1:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 3.5432329177856445 | ||
| ; | ||
|
|
||
| scoreMatchDisjunctionNonPushable | ||
| required_capability: score_function | ||
| required_capability: match_function | ||
|
|
||
| FROM books | ||
| | WHERE match(title, "Return") AND match(author, "Tolkien") | ||
| | EVAL s1 = score(match(title, "Rings") or ratings > 4.6) | ||
| | KEEP book_no, title, s1 | ||
| | SORT book_no | ||
| | LIMIT 5; | ||
|
|
||
| book_no:keyword | title:text | s1:double | ||
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 1.9245924949645996 | ||
| 7350 | Return of the Shadow | 0.0 | ||
| ; | ||
Uh oh!
There was an error while loading. Please reload this page.