jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1522511 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/ oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/
Date Thu, 12 Sep 2013 10:00:46 GMT
Author: thomasm
Date: Thu Sep 12 10:00:46 2013
New Revision: 1522511

URL: http://svn.apache.org/r1522511
Log:
OAK-890 Query: advanced fulltext search conditions (remove old code)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java?rev=1522511&r1=1522510&r2=1522511&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/ast/FullTextSearchImpl.java
Thu Sep 12 10:00:46 2013
@@ -41,13 +41,6 @@ import org.apache.jackrabbit.oak.spi.que
  * A fulltext "contains(...)" condition.
  */
 public class FullTextSearchImpl extends ConstraintImpl {
-    
-    /**
-     * Feature flag. 
-     * Disabled until OAK-890 is fully implemented.
-     * Enable for testing OAK-890 related changes.
-     */
-    public static final boolean OAK_890_ADVANCED_FT_SEARCH = true;
 
     /**
      * Compatibility for Jackrabbit 2.0 single quoted phrase queries.
@@ -87,13 +80,6 @@ public class FullTextSearchImpl extends 
             propertyName = propertyName.substring(slash + 1);
         }
 
-        if (!OAK_890_ADVANCED_FT_SEARCH) {
-            // temporary workaround to support using an index for
-            // "contains(a/*, 'x') or contains(a/a, x') or contains(a/b, 'x')"
-            // TODO this behavior does not match the specification
-            propertyName = null;
-        }
-
         if (propertyName == null || "*".equals(propertyName)) {
             this.propertyName = null;
         } else {
@@ -156,13 +142,11 @@ public class FullTextSearchImpl extends 
         PropertyValue v = fullTextSearchExpression.currentValue();
         try {
             String p = propertyName;
-            if (OAK_890_ADVANCED_FT_SEARCH) {
-                if (relativePath != null) {
-                    if (p == null) {
-                        p = "*";
-                    }
-                    p = PathUtils.concat(relativePath, p);
+            if (relativePath != null) {
+                if (p == null) {
+                    p = "*";
                 }
+                p = PathUtils.concat(relativePath, p);
             }
             return FullTextParser.parse(p, v.getValue(Type.STRING));
         } catch (ParseException e) {

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java?rev=1522511&r1=1522510&r2=1522511&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
Thu Sep 12 10:00:46 2013
@@ -32,7 +32,6 @@ import javax.jcr.query.RowIterator;
 
 import org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest;
 import org.apache.jackrabbit.oak.jcr.NodeStoreFixture;
-import org.apache.jackrabbit.oak.query.ast.FullTextSearchImpl;
 import org.junit.Test;
 
 /**
@@ -110,15 +109,10 @@ public class QueryFulltextTest extends A
         Query q;
         
         q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " + 
-                    "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",

-                    getResult(q.execute(), "plan"));
-        } else {
-            assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " + 
-                    "where contains([nt:base].[*], cast('hello OR hallo' as string)) */",

-                    getResult(q.execute(), "plan"));
-        }
+
+        assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " + 
+                "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",

+                getResult(q.execute(), "plan"));
         
         // verify the result
         // uppercase "OR" mean logical "or"

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java?rev=1522511&r1=1522510&r2=1522511&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
(original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryFulltextTest.java
Thu Sep 12 10:00:46 2013
@@ -27,7 +27,6 @@ import javax.jcr.query.QueryResult;
 import javax.jcr.query.RowIterator;
 
 import org.apache.jackrabbit.core.query.AbstractQueryTest;
-import org.apache.jackrabbit.oak.query.ast.FullTextSearchImpl;
 
 /**
  * Tests the fulltext index.
@@ -51,34 +50,19 @@ public class QueryFulltextTest extends A
         Query q;
         
         q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            // TODO the plan should actually be:
+
+// TODO the plan should actually be:
 //            assertEquals("[nt:base] as [nt:base] /* " + 
 //                    "+((text:hallo text:hello)~1) +text:{* TO *} " + 
 //                    "ft:(text:\"hallo\" OR text:\"hello\") " +
 //                    "where contains([nt:base].[text], cast('hello OR hallo' as string))
*/", 
 //                    getResult(q.execute(), "plan"));
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "aggregate +(:fulltext:hallo :fulltext:hello) +text:{* TO *} " + 
-                    "ft:(text:\"hallo\" OR text:\"hello\") " +
-                    "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",

-                    getResult(q.execute(), "plan"));
-        } else {
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "+:fulltext:hello +:fulltext:or +:fulltext:hallo " + 
-                    "where contains([nt:base].[*], cast('hello OR hallo' as string)) */",

-                    getResult(q.execute(), "plan"));
-            
-            // verify the result
-            // uppercase "OR" mean logical "or"
-            q = qm.createQuery(sql2, Query.JCR_SQL2);
-            if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-                assertEquals("/testroot/node1, /testroot/node2, /testroot/node3",
-                        getResult(q.execute(), "path"));
-            }
-
-        }
-
+        assertEquals("[nt:base] as [nt:base] /* " + 
+                "aggregate +(:fulltext:hallo :fulltext:hello) +text:{* TO *} " + 
+                "ft:(text:\"hallo\" OR text:\"hello\") " +
+                "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",

+                getResult(q.execute(), "plan"));
+   
         // lowercase "or" mean search for the term "or"
         sql2 = "select [jcr:path] as [path] from [nt:base] " + 
                 "where contains([text], 'hello or hallo') order by [jcr:path]";
@@ -104,22 +88,21 @@ public class QueryFulltextTest extends A
         String sql2 = "select [jcr:path] as [path] from [nt:base] " + 
                 "where ISCHILDNODE([/testroot])" + 
                 " AND CONTAINS(text, 'hallo')";
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
-            // TODO the plan should actually be:
+
+        q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
+        // TODO the plan should actually be:
 //          assertEquals("[nt:base] as [nt:base] /* " + 
 //                  "+text:hallo +:path:/testroot/* +text:{* TO *} " + 
 //                  "ft:(text:\"hallo\") " + 
 //                  "where (ischildnode([nt:base], [/testroot])) " + 
 //                  "and (contains([nt:base].[text], cast('hallo' as string))) */", 
 //                  getResult(q.execute(), "plan"));
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "aggregate +:fulltext:hallo* +:path:/testroot/* +text:{* TO *} " + 
-                    "ft:(text:\"hallo\") " + 
-                    "where (ischildnode([nt:base], [/testroot])) " + 
-                    "and (contains([nt:base].[text], cast('hallo' as string))) */", 
-                    getResult(q.execute(), "plan"));
-        }
+        assertEquals("[nt:base] as [nt:base] /* " + 
+                "aggregate +:fulltext:hallo* +:path:/testroot/* +text:{* TO *} " + 
+                "ft:(text:\"hallo\") " + 
+                "where (ischildnode([nt:base], [/testroot])) " + 
+                "and (contains([nt:base].[text], cast('hallo' as string))) */", 
+                getResult(q.execute(), "plan"));
         
         q = qm.createQuery(sql2, Query.JCR_SQL2);
         assertEquals("/testroot/node2, /testroot/node3", getResult(q.execute(), "path"));
@@ -136,56 +119,42 @@ public class QueryFulltextTest extends A
 //            getResult(q.execute(), "plan"));
 
         q = qm.createQuery(sql2, Query.JCR_SQL2);
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            assertEquals("/testroot", getResult(q.execute(), "path"));
-        }
+        assertEquals("/testroot", getResult(q.execute(), "path"));
         
         sql2 = "select [jcr:path] as [path] from [nt:base] " + 
                 "where contains([node2/text], 'hello OR hallo') order by [jcr:path]";
         q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            // TODO the plan should actually be:
+        // TODO the plan should actually be:
 //            assertEquals("[nt:base] as [nt:base] /* " + 
 //                    "(text:hallo text:hello)~1 " + 
 //                    "ft:(node2/text:\"hallo\" OR node2/text:\"hello\") " + 
 //                    "parent:node2 " + 
 //                    "where contains([nt:base].[node2/text], cast('hello OR hallo' as string))
*/", 
 //                    getResult(q.execute(), "plan"));
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "aggregate :fulltext:hallo* :fulltext:hello* " + 
-                    "ft:(node2/text:\"hallo\" OR node2/text:\"hello\") " + 
-                    "parent:node2 " + 
-                    "where contains([nt:base].[node2/text], cast('hello OR hallo' as string))
*/", 
-          getResult(q.execute(), "plan"));
-            q = qm.createQuery(sql2, Query.JCR_SQL2);
-            assertEquals("/testroot", 
-                    getResult(q.execute(), "path"));            
-        } else {
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "+:fulltext:hello +:fulltext:or +:fulltext:hallo " + 
-                    "where contains([nt:base].[node2/*], cast('hello OR hallo' as string))
*/", 
-                    getResult(q.execute(), "plan"));
-            q = qm.createQuery(sql2, Query.JCR_SQL2);
-            assertEquals("", 
-                    getResult(q.execute(), "path"));            
-        }
+        assertEquals("[nt:base] as [nt:base] /* " + 
+                "aggregate :fulltext:hallo* :fulltext:hello* " + 
+                "ft:(node2/text:\"hallo\" OR node2/text:\"hello\") " + 
+                "parent:node2 " + 
+                "where contains([nt:base].[node2/text], cast('hello OR hallo' as string))
*/", 
+      getResult(q.execute(), "plan"));
+        q = qm.createQuery(sql2, Query.JCR_SQL2);
+        assertEquals("/testroot", 
+                getResult(q.execute(), "path"));            
         
         sql2 = "select [jcr:path] as [path] from [nt:base] " + 
                 "where contains([node1/text], 'hello') " + 
                 "and contains([node2/text], 'hallo') " + 
                 "order by [jcr:path]";
         q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
-        if (FullTextSearchImpl.OAK_890_ADVANCED_FT_SEARCH) {
-            // TODO OAK-890
-            assertEquals("[nt:base] as [nt:base] /* " + 
-                    "aggregate Not yet implemented " + 
-                    "where (contains([nt:base].[node1/text], cast('hello' as string))) "
+ 
-                    "and (contains([nt:base].[node2/text], cast('hallo' as string))) */",

-                    getResult(q.execute(), "plan"));
-            q = qm.createQuery(sql2, Query.JCR_SQL2);
-            // assertEquals("/testroot", 
-            //        getResult(q.execute(), "path"));            
-        }
+        // TODO OAK-890
+        assertEquals("[nt:base] as [nt:base] /* " + 
+                "aggregate Not yet implemented " + 
+                "where (contains([nt:base].[node1/text], cast('hello' as string))) " + 
+                "and (contains([nt:base].[node2/text], cast('hallo' as string))) */", 
+                getResult(q.execute(), "plan"));
+        q = qm.createQuery(sql2, Query.JCR_SQL2);
+        // assertEquals("/testroot", 
+        //        getResult(q.execute(), "path"));            
         
     }
     



Mime
View raw message