|
| 1 | +############################################### |
| 2 | +# Tests for ExtractSnippets function |
| 3 | +# |
| 4 | + |
| 5 | +extractSnippetsWithField |
| 6 | +required_capability: extract_snippets_function |
| 7 | + |
| 8 | +// tag::extract-snippets-with-field[] |
| 9 | +FROM books |
| 10 | +| WHERE MATCH(description, "hobbit") |
| 11 | +| EVAL snippets = extract_snippets(description, "hobbit", 1, 25) |
| 12 | +// end::extract-snippets-with-field[] |
| 13 | +| KEEP book_no, author, title, snippets |
| 14 | +| SORT book_no |
| 15 | +| LIMIT 5 |
| 16 | +; |
| 17 | + |
| 18 | +// tag::extract-snippets-with-field-result[] |
| 19 | +book_no:keyword | author:text | title:text | snippets:keyword |
| 20 | +1463 | J. R. R. Tolkien | Realms of Tolkien: Images of Middle-earth | appropriate passage from The Hobbit |
| 21 | +2301 | John Ronald Reuel Tolkien | Smith of Wootton Major & Farmer Giles of Ham | beloved author of THE HOBBIT |
| 22 | +2675 | J.R.R. Tolkien | The Lord of the Rings - Boxed Set | Bilbo Baggins is a hobbit |
| 23 | +2714 | J. R. R. Tolkien | Return of the King Being the Third Part of The Lord of the Rings | the story begun in The Hobbit |
| 24 | +2936 | John Ronald Reuel Tolkien | Fellowship of the Ring 2ND Edition | into the hands of the hobbit |
| 25 | +// end::extract-snippets-with-field-result[] |
| 26 | +; |
| 27 | + |
| 28 | +extractMultipleSnippetsWithField |
| 29 | +required_capability: extract_snippets_function |
| 30 | + |
| 31 | +FROM books |
| 32 | +| WHERE MATCH(description, "hobbit") |
| 33 | +| EVAL snippets = extract_snippets(description, "hobbit", 3, 25) |
| 34 | +| KEEP book_no, author, title, snippets |
| 35 | +| SORT book_no |
| 36 | +| LIMIT 5 |
| 37 | +; |
| 38 | + |
| 39 | +book_no:keyword | author:text | title:text | snippets:keyword |
| 40 | +1463 | J. R. R. Tolkien | Realms of Tolkien: Images of Middle-earth | appropriate passage from The Hobbit |
| 41 | +2301 | John Ronald Reuel Tolkien | Smith of Wootton Major & Farmer Giles of Ham | beloved author of THE HOBBIT |
| 42 | +2675 | J.R.R. Tolkien | The Lord of the Rings - Boxed Set | [Bilbo Baggins is a hobbit, beautiful gift edition of The Hobbit, Tolkien's own children, The Hobbit] |
| 43 | +2714 | J. R. R. Tolkien | Return of the King Being the Third Part of The Lord of the Rings | [the story begun in The Hobbit, , THE HOBBIT: AN UNEXPECTED, film adaptation of The Hobbit] |
| 44 | +2936 | John Ronald Reuel Tolkien | Fellowship of the Ring 2ND Edition | into the hands of the hobbit |
| 45 | +; |
| 46 | + |
| 47 | + |
| 48 | +extractMultipleSnippetsWithFieldMvExpand |
| 49 | +required_capability: extract_snippets_function |
| 50 | + |
| 51 | +FROM books |
| 52 | +| WHERE MATCH(description, "hobbit") |
| 53 | +| EVAL snippets = extract_snippets(description, "hobbit", 3, 25) |
| 54 | +| MV_EXPAND snippets |
| 55 | +| KEEP book_no, author, title, snippets |
| 56 | +| SORT book_no |
| 57 | +| LIMIT 5 |
| 58 | +; |
| 59 | + |
| 60 | +book_no:keyword | author:text | title:text | snippets:keyword |
| 61 | +1463 | J. R. R. Tolkien | Realms of Tolkien: Images of Middle-earth | appropriate passage from The Hobbit |
| 62 | +2301 | John Ronald Reuel Tolkien | Smith of Wootton Major & Farmer Giles of Ham | beloved author of THE HOBBIT |
| 63 | +2675 | J.R.R. Tolkien | The Lord of the Rings - Boxed Set | beautiful gift edition of The Hobbit |
| 64 | +2675 | J.R.R. Tolkien | The Lord of the Rings - Boxed Set | Tolkien's own children, The Hobbit |
| 65 | +2675 | J.R.R. Tolkien | The Lord of the Rings - Boxed Set | Bilbo Baggins is a hobbit |
| 66 | +; |
| 67 | + |
| 68 | +extractMultipleSnippetsWithSomeNoMatches |
| 69 | +required_capability: extract_snippets_function |
| 70 | + |
| 71 | +FROM books |
| 72 | +| WHERE MATCH(author, "Faulkner") |
| 73 | +| EVAL snippets = extract_snippets(description, "slavery", 1, 10) |
| 74 | +| KEEP book_no, author, title, snippets |
| 75 | +| SORT book_no |
| 76 | +| LIMIT 5 |
| 77 | +; |
| 78 | + |
| 79 | +book_no:keyword | author:text | title:text | snippets:keyword |
| 80 | +2378 | [Carol Faulkner, Holly Byers Ochoa, Lucretia Mott] | Selected Letters of Lucretia Coffin Mott (Women in American History) | abolition of slavery |
| 81 | +2713 | William Faulkner | Collected Stories of William Faulkner | null |
| 82 | +2847 | Colleen Faulkner | To Love A Dark Stranger (Lovegram Historical Romance) | null |
| 83 | +2883 | William Faulkner | A Summer of Faulkner: As I Lay Dying/The Sound and the Fury/Light in August (Oprah's Book Club) | null |
| 84 | +3293 | Danny Faulkner | Universe by Design | null |
| 85 | +; |
| 86 | + |
| 87 | + |
| 88 | +extractSnippetsWithDefaultNumSnippetsAndLength |
| 89 | +required_capability: extract_snippets_function |
| 90 | + |
| 91 | +extractSnippetsCalledMultipleTimes |
| 92 | +required_capability: extract_snippets_function |
0 commit comments