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 function on 3-gram tokens. |
| 3 | * The index should be applied. |
| 4 | * Success : Yes |
| 5 | */ |
| 6 | |
| 7 | drop dataverse test if exists; |
| 8 | create dataverse test; |
| 9 | use dataverse test; |
| 10 | |
| 11 | create type DBLPType as closed { |
| 12 | id: int32, |
| 13 | dblpid: string, |
| 14 | title: string, |
| 15 | authors: string, |
| 16 | misc: string |
| 17 | } |
| 18 | |
| 19 | create dataset DBLP(DBLPType) partitioned by key id; |
| 20 | |
| 21 | load dataset DBLP |
| 22 | using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter" |
| 23 | (("path"="nc1://data/dblp-small/dblp-small-id.txt"),("format"="delimited-text"),("delimiter"=":")) pre-sorted; |
| 24 | |
| 25 | create index ngram_index on DBLP(title) type ngram(3); |
| 26 | |
| 27 | write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm"; |
| 28 | |
| 29 | for $o in dataset('DBLP') |
| 30 | where similarity-jaccard(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false)) >= 0.5f |
| 31 | return $o |