alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Description : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens. |
| 3 | * Tests that the optimizer rule correctly drills through the let clauses. |
| 4 | * The index should be applied. |
| 5 | * Success : Yes |
| 6 | */ |
| 7 | |
| 8 | drop dataverse test if exists; |
| 9 | create dataverse test; |
| 10 | use dataverse test; |
| 11 | |
| 12 | create type DBLPType as closed { |
| 13 | id: int32, |
| 14 | dblpid: string, |
| 15 | title: string, |
| 16 | authors: string, |
| 17 | misc: string |
| 18 | } |
| 19 | |
ramangrover29 | 669d8f6 | 2013-02-11 06:03:32 +0000 | [diff] [blame] | 20 | create dataset DBLP(DBLPType) primary key id; |
alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 21 | |
alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 22 | create index ngram_index on DBLP(title) type ngram(3); |
| 23 | |
| 24 | write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm"; |
| 25 | |
| 26 | // This test is complex because we have three assigns to drill into. |
| 27 | for $paper in dataset('DBLP') |
| 28 | let $paper_tokens := gram-tokens($paper.title, 3, false) |
| 29 | let $query_tokens := gram-tokens("Transactions for Cooperative Environments", 3, false) |
| 30 | let $jacc := similarity-jaccard-check($paper_tokens, $query_tokens, 0.5f) |
| 31 | where $jacc[0] |
| 32 | return {"Paper": $paper_tokens, "Query": $query_tokens } |