asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ima...@apache.org
Subject [40/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:06 GMT
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-36.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-36.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-36.aql
new file mode 100644
index 0000000..e75a51e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-36.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname <= "Vanpatten"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-37.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-37.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-37.aql
new file mode 100644
index 0000000..0392da2
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-37.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname != "Max"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-38.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-38.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-38.aql
new file mode 100644
index 0000000..780febf
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-38.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname = "Julio"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-39.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-39.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-39.aql
new file mode 100644
index 0000000..5010a5b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-39.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.lname = "Kim"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-40.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-40.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-40.aql
new file mode 100644
index 0000000..ee7c3a8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-40.aql
@@ -0,0 +1,30 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-38.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname = "Young Seok" and $emp.nested.lname = "Kim"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-41.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-41.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-41.aql
new file mode 100644
index 0000000..17420cb
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-41.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname = "Julio" or $emp.nested.lname = "Malaika"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-42.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-42.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-42.aql
new file mode 100644
index 0000000..0e3f2aa
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-42.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-40.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Alex" and $emp.nested.lname < "Zach"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-43.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-43.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-43.aql
new file mode 100644
index 0000000..7588fb4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-43.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-41.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Allan" and $emp.nested.lname < "Zubi"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-44.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-44.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-44.aql
new file mode 100644
index 0000000..4cbb105
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-44.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Allan" and $emp.nested.lname = "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-45.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-45.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-45.aql
new file mode 100644
index 0000000..6e13058
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-45.aql
@@ -0,0 +1,33 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+// 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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname = "Julio" and $emp.nested.lname < "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-46.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-46.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-46.aql
new file mode 100644
index 0000000..d48edc1
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-46.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-44.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname >= "Michael" and $emp.nested.lname <= "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-47.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-47.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-47.aql
new file mode 100644
index 0000000..252f67a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-47.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-45.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Craig" and $emp.nested.lname > "Kevin" and $emp.nested.fname < "Mary" and $emp.nested.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-48.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-48.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-48.aql
new file mode 100644
index 0000000..6fa1ba9
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-48.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-46.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname >= "Craig" and $emp.nested.lname >= "Kevin" and $emp.nested.fname <= "Mary" and $emp.nested.lname <= "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-49.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-49.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-49.aql
new file mode 100644
index 0000000..14df382
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-49.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-47.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname <= "Craig" and $emp.nested.lname > "Kevin"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-50.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-50.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-50.aql
new file mode 100644
index 0000000..bede346
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-50.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-48.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname != "Michael" and $emp.nested.lname != "Carey"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-51.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-51.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-51.aql
new file mode 100644
index 0000000..28b0e02
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-51.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-49.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Craig" and $emp.nested.lname > "Kevin" and $emp.nested.fname <= "Mary" and $emp.nested.lname <= "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-52.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-52.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-52.aql
new file mode 100644
index 0000000..4033590
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-52.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-50.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname >= "Craig" and $emp.nested.lname >= "Kevin" and $emp.nested.fname < "Mary" and $emp.nested.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-53.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-53.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-53.aql
new file mode 100644
index 0000000..d21c83b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-53.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-51.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname >= "Craig" and $emp.nested.lname <= "Kevin" and $emp.nested.fname <= "Mary" and $emp.nested.lname >= "Tomes"
+return $emp

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

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

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

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

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

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

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

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql
new file mode 100644
index 0000000..6ee2dd4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-61.aql
@@ -0,0 +1,31 @@
+/*
+ *  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            : 13th Aug 2012
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+write output to nc1:"rttest/btree-index_btree-secondary-61.adm";
+
+create type TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst')
+where $emp.nested.fname > "Craig" and $emp.nested.lname > "Kevin" and $emp.nested.fname <= "Mary" and $emp.nested.lname < "Tomes"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql
new file mode 100644
index 0000000..e5f67ba
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-62.aql
@@ -0,0 +1,33 @@
+/*
+ *  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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst') 
+where $emp.nested.fname = "Julio" and $emp.nested.lname > "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql
new file mode 100644
index 0000000..53d06f4
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/btree-index/btree-secondary-63.aql
@@ -0,0 +1,33 @@
+/*
+ *  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 TestTypetmp as open {
+    id : int32,
+    fname : string,
+    lname : string
+}
+
+create type TestType as open {
+    nested : TestTypetmp
+}
+
+create dataset testdst(TestType) primary key nested.id;
+
+create index sec_Idx on testdst(nested.fname,nested.lname);
+
+for $emp in dataset('testdst') 
+where $emp.nested.fname < "Julio" and $emp.nested.lname = "Xu"
+return $emp

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql
new file mode 100644
index 0000000..dac719f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains-panic.aql
@@ -0,0 +1,33 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+
+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.nested.title, "Mu")
+order by $o.nested.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/nested-index/inverted-index-basic/ngram-contains.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql
new file mode 100644
index 0000000..e143b37
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-contains.aql
@@ -0,0 +1,32 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-contains.adm";
+
+for $o in dataset('DBLP')
+where contains($o.nested.title, "Multimedia")
+order by $o.nested.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/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.aql
new file mode 100644
index 0000000..f863218
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check-panic.aql
@@ -0,0 +1,33 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.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/nested-index/inverted-index-basic/ngram-edit-distance-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql
new file mode 100644
index 0000000..5be236a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-check.aql
@@ -0,0 +1,31 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance-check.adm";
+
+for $o in dataset('DBLP')
+where edit-distance-check($o.nested.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/nested-index/inverted-index-basic/ngram-edit-distance-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-panic.aql
new file mode 100644
index 0000000..19c1257
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance-panic.aql
@@ -0,0 +1,32 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.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/nested-index/inverted-index-basic/ngram-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql
new file mode 100644
index 0000000..452ab86
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-edit-distance.aql
@@ -0,0 +1,31 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-edit-distance.adm";
+
+for $o in dataset('DBLP')
+where edit-distance($o.nested.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/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
new file mode 100644
index 0000000..75d0c5e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-edit-distance.aql
@@ -0,0 +1,34 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.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/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..bacacc0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-fuzzyeq-jaccard.aql
@@ -0,0 +1,35 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+
+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.nested.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/nested-index/inverted-index-basic/ngram-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.aql
new file mode 100644
index 0000000..5b6205b
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard-check.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.
+ *                  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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard-check.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard-check(gram-tokens($o.nested.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/nested-index/inverted-index-basic/ngram-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql
new file mode 100644
index 0000000..f69f98e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ngram-jaccard.aql
@@ -0,0 +1,32 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.title) type ngram(3);
+
+write output to nc1:"rttest/inverted-index-basic_ngram-jaccard.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard(gram-tokens($o.nested.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/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql
new file mode 100644
index 0000000..f985ba8
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check-panic.aql
@@ -0,0 +1,44 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check-panic.adm";
+
+// Index should not be applied because all list elements can be modified by 3 edit operations.
+for $c in dataset('Customers')
+where edit-distance-check($c.nested.interests, ["computers", "wine", "walking"], 3)[0]
+order by $c.nested.cid
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql
new file mode 100644
index 0000000..c229174
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-check.aql
@@ -0,0 +1,42 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-check.adm";
+
+for $c in dataset('Customers')
+where edit-distance-check($c.nested.interests, ["computers", "wine", "walking"], 1)[0]
+order by $c.nested.cid
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql
new file mode 100644
index 0000000..40e9bcc
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance-panic.aql
@@ -0,0 +1,44 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should *not* be applied (see below).
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance-panic.adm";
+
+// Index should not be applied because all list elements can be modified by 3 edit operations.
+for $c in dataset('Customers')
+where edit-distance($c.nested.interests, ["computers", "wine", "walking"]) <= 3
+order by $c.nested.cid
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql
new file mode 100644
index 0000000..4ee920f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-edit-distance.aql
@@ -0,0 +1,43 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the edit-distance function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-edit-distance.adm";
+
+for $c in dataset('Customers')
+where edit-distance($c.nested.interests, ["computers", "wine", "walking"]) <= 1
+order by $c.nested.cid
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
new file mode 100644
index 0000000..48e4dc5
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-edit-distance.aql
@@ -0,0 +1,43 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query with ~= using edit-distance on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-edit-distance.adm";
+
+set simfunction 'edit-distance';
+set simthreshold '1';
+
+for $c in dataset('Customers')
+where $c.nested.interests ~= ["computers", "wine", "walking"]
+order by $c.nested.cid
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..b85adb0
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-fuzzyeq-jaccard.aql
@@ -0,0 +1,42 @@
+/*
+ * Description    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-fuzzyeq-jaccard.adm";
+
+set simfunction 'jaccard';
+set simthreshold '0.8f';
+
+for $c in dataset('Customers')
+where $c.nested.interests ~= ["databases", "computers", "wine"]
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql
new file mode 100644
index 0000000..b51c59e
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard-check.aql
@@ -0,0 +1,39 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard-check.adm";
+
+for $c in dataset('Customers')
+where similarity-jaccard-check($c.nested.interests, ["databases", "computers", "wine"], 0.7f)[0]
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql
new file mode 100644
index 0000000..12e4db7
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/olist-jaccard.aql
@@ -0,0 +1,40 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on lists.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: [string],
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_olist-jaccard.adm";
+
+for $c in dataset('Customers')
+where similarity-jaccard($c.nested.interests, ["databases", "computers", "wine"]) >= 0.7f
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..45aa472
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-fuzzyeq-jaccard.aql
@@ -0,0 +1,43 @@
+/*
+ * Description    : Tests whether a keyword is applied to optimize a selection query with ~= using Jaccard on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: {{string}},
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-fuzzyeq-jaccard.adm";
+
+set simfunction 'jaccard';
+set simthreshold '0.8f';
+
+for $c in dataset('Customers')
+where $c.nested.interests ~= {{"computers", "wine", "databases"}}
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql
new file mode 100644
index 0000000..a5c391a
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard-check.aql
@@ -0,0 +1,40 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard-check function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: {{string}},
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm";
+
+for $c in dataset('Customers')
+where similarity-jaccard-check($c.nested.interests, {{"computers", "wine", "databases"}}, 0.7f)[0]
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql
new file mode 100644
index 0000000..e460413
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/ulist-jaccard.aql
@@ -0,0 +1,40 @@
+/*
+ * Description    : Tests whether a keyword index is applied to optimize a selection query using the similarity-jaccard function on sets.
+ *                  The index should be applied.
+ * Success        : Yes
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type AddressType as closed {
+  number: int32,
+  street: string,
+  city: string
+}
+
+create type CustomerTypetmp as closed {
+  cid: int32,
+  name: string,
+  age: int32?,
+  address: AddressType?,
+  interests: {{string}},
+  children: [ { name: string, age: int32? } ]
+}
+
+create type CustomerType as closed {
+  nested : CustomerTypetmp
+}
+
+create dataset Customers(CustomerType) primary key nested.cid;
+ 
+create dataset Customers2(CustomerType) primary key nested.cid;
+
+create index interests_index on Customers(nested.interests) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_ulist-jaccard.adm";
+
+for $c in dataset('Customers')
+where similarity-jaccard($c.nested.interests, {{"computers", "databases", "wine"}}) >= 0.7f
+return $c

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql
new file mode 100644
index 0000000..938b1cd
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-contains.aql
@@ -0,0 +1,33 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+
+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.nested.title, "Multimedia")
+order by $o.nested.id
+return $o

http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/04b2b77a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql
new file mode 100644
index 0000000..42beb01
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-fuzzyeq-jaccard.aql
@@ -0,0 +1,34 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+
+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.nested.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/nested-index/inverted-index-basic/word-jaccard-check.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql
new file mode 100644
index 0000000..23ddf3f
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard-check.aql
@@ -0,0 +1,32 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard-check.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard-check(word-tokens($o.nested.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/nested-index/inverted-index-basic/word-jaccard.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql
new file mode 100644
index 0000000..d5d80e6
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-basic/word-jaccard.aql
@@ -0,0 +1,32 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index keyword_index on DBLP(nested.title) type keyword;
+
+write output to nc1:"rttest/inverted-index-basic_word-jaccard.adm";
+
+for $o in dataset('DBLP')
+where similarity-jaccard(word-tokens($o.nested.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/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
new file mode 100644
index 0000000..8f4f620
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_01.aql
@@ -0,0 +1,36 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.authors, "Amihay Motro", 3)
+let $edb := edit-distance-check($o.nested.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/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
new file mode 100644
index 0000000..c0aec78
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic-nopanic_02.aql
@@ -0,0 +1,36 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.authors, "Amihay Motro", 5)
+let $eda := edit-distance-check($o.nested.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/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
----------------------------------------------------------------------
diff --git a/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.aql b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
new file mode 100644
index 0000000..987b105
--- /dev/null
+++ b/asterix-app/src/test/resources/optimizerts/queries/nested-index/inverted-index-complex/ngram-edit-distance-check-let-panic.aql
@@ -0,0 +1,34 @@
+/*
+ * 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 DBLPTypetmp as closed {
+  id: int32,
+  dblpid: string,
+  title: string,
+  authors: string,
+  misc: string
+}
+
+create type DBLPType as closed {
+  nested : DBLPTypetmp
+}
+
+create dataset DBLP(DBLPType) primary key nested.id;
+
+create index ngram_index on DBLP(nested.authors) type ngram(3);
+
+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.nested.authors, "Amihay Motro", 5)
+where $ed[0]
+return $o
\ No newline at end of file


Mime
View raw message