asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject [35/58] [abbrv] [partial] incubator-asterixdb git commit: Added support of typed indexes over open fields & indexes over nested fields
Date Fri, 24 Apr 2015 18:43:01 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_03.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_03.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_03.aql
new file mode 100644
index 0000000..7db8cfa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_03.aql
@@ -0,0 +1,28 @@
+/*
+ * Description    : Equi self-joins a dataset, DBLP, based on its title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index title_index on DBLP(title:string) enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_03.adm";
+
+for $a in dataset('DBLP')
+for $b in dataset('DBLP')
+where $a.title /*+ indexnl */ = $b.title
+return {"arec": $a, "brec": $b}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_04.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_04.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_04.aql
new file mode 100644
index 0000000..0df583b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_04.aql
@@ -0,0 +1,39 @@
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  Both DBLP and CSX have secondary btree open index on title, and given the 'indexnl' hint
+ *                  we expect the join to be transformed into an indexed nested-loop join.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as open {
+  id: int32,
+  csxid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create dataset CSX(CSXType) primary key id;
+
+create index title_index_DBLP on DBLP(title:string) enforced;
+
+create index title_index on CSX(title:string) enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm";
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+where $a.title /*+ indexnl */ = $b.title
+return {"arec": $a, "brec": $b}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_05.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_05.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_05.aql
new file mode 100644
index 0000000..289834d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index-join/secondary-equi-join_05.aql
@@ -0,0 +1,38 @@
+/*
+ * Description    : Equi joins two datasets, DBLP and CSX, based on their title.
+ *                  DBLP has a secondary btree open index on title, and given the 'indexnl' hint
+ *                  we *do not* expect the join to be transformed into an indexed nested-loop join,
+ *                  because CSX does not declare an enforced open index on field title.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create type CSXType as open {
+  id: int32,
+  csxid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create dataset CSX(CSXType) primary key id;
+
+create index title_index on DBLP(title:string) enforced;
+
+write output to nc1:"rttest/btree-index-join_title-secondary-equi-join_02.adm";
+
+for $a in dataset('DBLP')
+for $b in dataset('CSX')
+where $a.title /*+ indexnl */ = $b.title
+return {"arec": $a, "brec": $b}

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-33.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-33.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-33.aql
new file mode 100644
index 0000000..e453a06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-33.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Please note this is a Negative test and the BTree index should NOT be used in the plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-31.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Roger"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-34.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-34.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-34.aql
new file mode 100644
index 0000000..7786be7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-34.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// This is a Negative test - prefix search, BTree index should not be used in the plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-32.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Susan"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-35.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-35.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-35.aql
new file mode 100644
index 0000000..9cbf40e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-35.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification (usage) test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - prefix search, BTree index should not be used.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-33.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname < "Isa"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-36.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-36.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-36.aql
new file mode 100644
index 0000000..2afd8f1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-36.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - prefix search, BTree index should not be used in query plan
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-34.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname <= "Vanpatten"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-37.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-37.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-37.aql
new file mode 100644
index 0000000..1ce15ec
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-37.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - BTree index should NOT be used in query plan
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-35.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname != "Max"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-38.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-38.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-38.aql
new file mode 100644
index 0000000..e5ce49d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-38.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - prefix search, BTree index should NOT be used in the query plan.
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-36.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname = "Julio"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-39.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-39.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-39.aql
new file mode 100644
index 0000000..28e6232
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-39.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// THE BTREE INDEX IN THIS CASE SHOULD NOT BE PICKED UP!!!!
+// Verify that the optimized query plan does not have the BTree search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-37.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.lname = "Kim"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-40.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-40.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-40.aql
new file mode 100644
index 0000000..37af737
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-40.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname = "Young Seok" and $emp.lname = "Kim"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-41.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-41.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-41.aql
new file mode 100644
index 0000000..12bd703
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-41.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-39.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname = "Julio" or $emp.lname = "Malaika"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-42.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-42.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-42.aql
new file mode 100644
index 0000000..f4ac093
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-42.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Alex" and $emp.lname < "Zach"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-43.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-43.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-43.aql
new file mode 100644
index 0000000..5825e2d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-43.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Allan" and $emp.lname < "Zubi"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-44.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-44.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-44.aql
new file mode 100644
index 0000000..d1b8ad6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-44.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-42.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Allan" and $emp.lname = "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-45.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-45.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-45.aql
new file mode 100644
index 0000000..95c2e6d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-45.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+// Negative test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-43.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname = "Julio" and $emp.lname < "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-46.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-46.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-46.aql
new file mode 100644
index 0000000..ffeabbf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-46.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Michael" and $emp.lname <= "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-47.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-47.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-47.aql
new file mode 100644
index 0000000..fdb67ca
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-47.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-48.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-48.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-48.aql
new file mode 100644
index 0000000..809d406
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-48.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-49.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-49.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-49.aql
new file mode 100644
index 0000000..38f9996
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-49.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname <= "Craig" and $emp.lname > "Kevin"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-50.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-50.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-50.aql
new file mode 100644
index 0000000..b96805b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-50.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is NOT used
+ *                  : in the optimized query plan
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname != "Michael" and $emp.lname != "Carey"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-51.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-51.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-51.aql
new file mode 100644
index 0000000..b549505
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-51.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname <= "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-52.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-52.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-52.aql
new file mode 100644
index 0000000..f2f534e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-52.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Craig" and $emp.lname >= "Kevin" and $emp.fname < "Mary" and $emp.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-53.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-53.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-53.aql
new file mode 100644
index 0000000..73bde18
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-53.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Craig" and $emp.lname <= "Kevin" and $emp.fname <= "Mary" and $emp.lname >= "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-54.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-54.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-54.aql
new file mode 100644
index 0000000..53cb2bb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-54.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-52.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Max"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-55.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-55.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-55.aql
new file mode 100644
index 0000000..f8b58da
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-55.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-53.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Sofia"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-56.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-56.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-56.aql
new file mode 100644
index 0000000..cd79ae9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-56.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-54.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname < "Chen"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-57.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-57.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-57.aql
new file mode 100644
index 0000000..06dec30
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-57.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-55.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname <= "Julio"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-58.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-58.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-58.aql
new file mode 100644
index 0000000..a9bcdc9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-58.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the primary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-primary-56.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Neil" and $emp.fname < "Roger"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-59.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-59.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-59.aql
new file mode 100644
index 0000000..f93e66d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-59.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-57.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname >= "Max" and $emp.fname <= "Roger"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-60.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-60.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-60.aql
new file mode 100644
index 0000000..cafc301
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-60.aql
@@ -0,0 +1,24 @@
+/*
+ *  Description     : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-58.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname = "Max"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-61.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-61.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-61.aql
new file mode 100644
index 0000000..36aca34
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-61.aql
@@ -0,0 +1,25 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 26th Mar 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst')
+where $emp.fname > "Craig" and $emp.lname > "Kevin" and $emp.fname <= "Mary" and $emp.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-62.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-62.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-62.aql
new file mode 100644
index 0000000..b325b2d
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-62.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+// Positive test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-62.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst') 
+where $emp.fname = "Julio" and $emp.lname > "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-63.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-63.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-63.aql
new file mode 100644
index 0000000..14d18c7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/btree-index/btree-secondary-63.aql
@@ -0,0 +1,27 @@
+/*
+ *  Description     : BTree Index verification test
+ *                  : This test is intended to verify that the secondary BTree index is used 
+ *                  : in the optimized query plan.
+ *  Expected Result : Success
+ *  Date            : 11th Nov 2014
+ */
+
+// Positive test - prefix search
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-63.adm";
+
+create type TestType as open {
+    id : int32
+}
+
+create dataset testdst(TestType) primary key id;
+
+create index sec_Idx on testdst(fname:string,lname:string) enforced;
+
+for $emp in dataset('testdst') 
+where $emp.fname < "Julio" and $emp.lname = "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains-panic.aql
new file mode 100644
index 0000000..3a4bc5e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains-panic.aql
@@ -0,0 +1,28 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains-panic.adm";
+
+// Cannot optimize this query because the string constant is shorter than the gram length.
+for $o in dataset('DBLP')
+where contains($o.title, "Mu")
+order by $o.id
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains.aql
new file mode 100644
index 0000000..c4ce184
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-contains.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the contains function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm";
+
+for $o in dataset('DBLP')
+where contains($o.title, "Multimedia")
+order by $o.id
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.aql
new file mode 100644
index 0000000..7282675
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check-panic.aql
@@ -0,0 +1,28 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check-panic.adm";
+
+// This query cannot be optimized with an index, based on the high edit distance.
+for $o in dataset('DBLP')
+let $ed := edit-distance-check($o.authors, "Amihay Motro", 5)
+where $ed[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.aql
new file mode 100644
index 0000000..5661e42
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-check.aql
@@ -0,0 +1,26 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm";
+
+for $o in dataset('DBLP')
+where edit-distance-check($o.authors, "Amihay Motro", 1)[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.aql
new file mode 100644
index 0000000..0210ea5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance-panic.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-panic.adm";
+
+// This query cannot be optimized with an index, based on the high edit distance.
+for $o in dataset('DBLP')
+where edit-distance($o.authors, "Amihay Motro") <= 5
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance.aql
new file mode 100644
index 0000000..197f798
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-edit-distance.aql
@@ -0,0 +1,26 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance function on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm";
+
+for $o in dataset('DBLP')
+where edit-distance($o.authors, "Amihay Motro") <= 1
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
new file mode 100644
index 0000000..6bf84ac
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
@@ -0,0 +1,29 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query with ~= using edit-distance on strings.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-edit-distance.adm";
+
+set simfunction 'edit-distance';
+set simthreshold '1';
+
+for $o in dataset('DBLP')
+where $o.authors ~= "Amihay Motro"
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..f713564
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
@@ -0,0 +1,30 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query with ~= using Jaccard on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+set import-private-functions 'true';
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-fuzzyeq-jaccard.adm";
+
+set simfunction 'jaccard';
+set simthreshold '0.8f';
+
+for $o in dataset('DBLP')
+where gram-tokens($o.title, 3, false) ~= gram-tokens("Transactions for Cooperative Environments", 3, false)
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard-check.aql
new file mode 100644
index 0000000..10188ff
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard-check.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+set import-private-functions 'true';
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard-check(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)[0]
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard.aql
new file mode 100644
index 0000000..0e5e44f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/ngram-jaccard.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard function on 3-gram tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+set import-private-functions 'true';
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false)) >= 0.5f
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-contains.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-contains.aql
new file mode 100644
index 0000000..97bd041
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-contains.aql
@@ -0,0 +1,28 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the contains function.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-contains.adm";
+
+// Contains cannot be answered with a word inverted index.
+for $o in dataset('DBLP')
+where contains($o.title, "Multimedia")
+order by $o.id
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..3f12672
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-fuzzyeq-jaccard.aql
@@ -0,0 +1,29 @@
+/*
+ * Description    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-fuzzyeq-jaccard.adm";
+
+set simfunction 'jaccard';
+set simthreshold '0.5f';
+
+for $o in dataset('DBLP')
+where word-tokens($o.title) ~= word-tokens("Transactions for Cooperative Environments")
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard-check.aql
new file mode 100644
index 0000000..a933e4f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard-check.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard-check(word-tokens($o.title), word-tokens("Transactions for Cooperative Environments"), 0.5f)[0]
+return $o
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard.aql
new file mode 100644
index 0000000..e73fe86
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-basic/word-jaccard.aql
@@ -0,0 +1,27 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on word tokens.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard(word-tokens($o.title), word-tokens("Transactions for Cooperative Environments")) >= 0.5f
+return $o
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
new file mode 100644
index 0000000..b9a5859
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the first can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm";
+
+// Only the first edit-distance-check can be optimized with an index.
+for $o in dataset('DBLP')
+let $eda := edit-distance-check($o.authors, "Amihay Motro", 3)
+let $edb := edit-distance-check($o.authors, "Amihay Motro", 5)
+where $eda[0] and $edb[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
new file mode 100644
index 0000000..617c59c
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using
+ *                  two edit-distance-check function of which only the second can be optimized with an index.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic-nopanic_01.adm";
+
+// Only the second edit-distance-check can be optimized with an index.
+for $o in dataset('DBLP')
+let $edb := edit-distance-check($o.authors, "Amihay Motro", 5)
+let $eda := edit-distance-check($o.authors, "Amihay Motro", 3)
+where $edb[0] and $eda[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
new file mode 100644
index 0000000..6c2c664
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
@@ -0,0 +1,29 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let-panic.adm";
+
+// This query cannot be optimized with an index, based on the high edit distance.
+for $o in dataset('DBLP')
+let $ed := edit-distance-check($o.authors, "Amihay Motro", 5)
+where $ed[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.aql
new file mode 100644
index 0000000..61f570f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-let.aql
@@ -0,0 +1,28 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the edit-distance-check function on strings.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  title: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(authors:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-let.adm";
+
+for $o in dataset('DBLP')
+let $ed := edit-distance-check($o.authors, "Amihay Motro", 1)
+where $ed[0]
+return $o
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.aql
new file mode 100644
index 0000000..8327274
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-substring.aql
@@ -0,0 +1,30 @@
+/*
+ * Description    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on the substring of the field.
+ *                  Tests that the optimizer rule correctly drills through the substring function.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title: string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-substring.adm";
+
+for $paper in dataset('DBLP')
+where edit-distance-check(substring($paper.title, 0, 8), "datbase", 1)[0]
+return {
+  "id" : $paper.id,
+  "title" : $paper.title
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.aql
new file mode 100644
index 0000000..2e45f80
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-edit-distance-check-word-tokens.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Tests whether an ngram_index index is applied to optimize a selection query using the similarity-edit-distance-check function on individual word tokens.
+ *                  Tests that the optimizer rule correctly drills through the word-tokens function and existential query.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title: string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-edit-distance-check-word-tokens.adm";
+
+for $paper in dataset('DBLP')
+for $word in word-tokens($paper.title)
+where edit-distance-check($word, "Multmedia", 1)[0]
+distinct by $paper.id
+return {
+  "id" : $paper.id,
+  "title" : $paper.title
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.aql
new file mode 100644
index 0000000..5a9f136
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-let.aql
@@ -0,0 +1,29 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+set import-private-functions 'true';
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-let.adm";
+
+for $o in dataset('DBLP')
+let $jacc := similarity-jaccard-check(gram-tokens($o.title, 3, false), gram-tokens("Transactions for Cooperative Environments", 3, false), 0.5f)
+where $jacc[0]
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.aql
new file mode 100644
index 0000000..c66bdd8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/ngram-jaccard-check-multi-let.aql
@@ -0,0 +1,32 @@
+/*
+ * Description    : Tests whether an ngram_index is applied to optimize a selection query using the similarity-jaccard-check function on 3-gram tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+set import-private-functions 'true';
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index ngram_index on DBLP(title:string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-complex_ngram-jaccard-check-multi-let.adm";
+
+// This test is complex because we have three assigns to drill into.
+for $paper in dataset('DBLP')
+let $paper_tokens := gram-tokens($paper.title, 3, false)
+let $query_tokens := gram-tokens("Transactions for Cooperative Environments", 3, false)
+let $jacc := similarity-jaccard-check($paper_tokens, $query_tokens, 0.5f)
+where $jacc[0]
+return {"Paper": $paper_tokens, "Query": $query_tokens }

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-let.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-let.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-let.aql
new file mode 100644
index 0000000..3fb50bd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-let.aql
@@ -0,0 +1,29 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-let.adm";
+
+for $o in dataset('DBLP')
+let $jacc := similarity-jaccard-check(word-tokens($o.title), word-tokens("Transactions for Cooperative Environments"), 0.5f)
+where $jacc[0]
+return $o
+

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.aql
new file mode 100644
index 0000000..afc4c06
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-complex/word-jaccard-check-multi-let.aql
@@ -0,0 +1,31 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on word tokens.
+ *                  Tests that the optimizer rule correctly drills through the let clauses.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type DBLPType as open {
+  id: int32,
+  dblpid: string,
+  authors: string,
+  misc: string
+}
+
+create dataset DBLP(DBLPType) primary key id;
+
+create index keyword_index on DBLP(title:string) type keyword enforced;
+
+write output to nc1:"rttest/inverted-index-complex_word-jaccard-check-multi-let.adm";
+
+// This test is complex because we have three assigns to drill into.
+for $paper in dataset('DBLP')
+let $paper_tokens := word-tokens($paper.title)
+let $query_tokens := word-tokens("Transactions for Cooperative Environments")
+let $jacc := similarity-jaccard-check($paper_tokens, $query_tokens, 0.8f)
+where $jacc[0]
+return {"Paper": $paper_tokens, "Query": $query_tokens }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.aql b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.aql
new file mode 100644
index 0000000..572ff63
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/open-index-enforced/inverted-index-join/leftouterjoin-probe-pidx-with-join-edit-distance-check-idx_01.aql
@@ -0,0 +1,49 @@
+/*
+ * Description  : Test that left-outer-join may use two available indexes, one for primary index in prob subtree and another for secondary rtree index in index subtree.
+ * Issue        : 730, 741
+ * Expected Res : Success
+ * Date         : 8th May 2014
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type TwitterUserType as closed {
+	screen-name: string,
+	lang: string,
+	friends-count: int32,
+	statuses-count: int32,
+	name: string,
+	followers-count: int32
+}
+
+create type TweetMessageType as open {
+	tweetid: int64,
+        user: TwitterUserType,
+        sender-location: point,
+	send-time: datetime,
+        referred-topics: {{ string }},
+	countA: int32,
+	countB: int32
+}
+
+create dataset TweetMessages(TweetMessageType)
+primary key tweetid;
+
+create index msgNgramIx on TweetMessages(message-text: string) type ngram(3) enforced;
+
+write output to nc1:"rttest/inverted-index-join_leftouterjoin-probe-pidx-with-join-edit-distance-check_idx_01.adm";
+
+for $t1 in dataset('TweetMessages')
+where $t1.tweetid > int64("240")
+order by $t1.tweetid
+return {
+    "tweet": {"id": $t1.tweetid, "topics" : $t1.message-text} ,
+    "similar-tweets": for $t2 in dataset('TweetMessages')
+                      let $sim := edit-distance-check($t1.message-text, $t2.message-text, 7)
+		      where $sim[0] and
+                      $t2.tweetid != $t1.tweetid
+                      order by $t2.tweetid
+                      return {"id": $t2.tweetid, "topics" : $t2.message-text}
+};
\ No newline at end of file


Mime
View raw message