jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1585486 - in /jackrabbit/oak/trunk/oak-solr-core: ./ src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/ src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/ src/main/resources/solr/oak/conf/ src/test/jav...
Date Mon, 07 Apr 2014 14:08:20 GMT
Author: tommaso
Date: Mon Apr  7 14:08:19 2014
New Revision: 1585486

URL: http://svn.apache.org/r1585486
Log:
OAK-1673 - added FulltextQueryTest to Solr, fixed minor bugs

Modified:
    jackrabbit/oak/trunk/oak-solr-core/pom.xml
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/schema.xml
    jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/solrconfig.xml

Modified: jackrabbit/oak/trunk/oak-solr-core/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/pom.xml?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/pom.xml Mon Apr  7 14:08:19 2014
@@ -32,6 +32,13 @@
     <description>Oak support for Apache Solr indexing and search</description>
     <packaging>bundle</packaging>
 
+    <properties>
+        <known.issues>
+            org.apache.jackrabbit.core.query.FulltextQueryTest#testMultipleOrExpressions
                   <!-- different ranking -->
+            org.apache.jackrabbit.core.query.FulltextQueryTest#testMultiByte            
                   <!-- wildcards with multi byte support -->
+        </known.issues>
+    </properties>
+
     <build>
         <plugins>
             <plugin>

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java
Mon Apr  7 14:08:19 2014
@@ -20,7 +20,7 @@ import org.apache.jackrabbit.oak.api.Typ
 import org.apache.jackrabbit.oak.spi.query.Filter;
 
 /**
- * An {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}
for the embedded Solr server
+ * Default {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}
  */
 public class DefaultSolrConfiguration implements OakSolrConfiguration {
 

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java
Mon Apr  7 14:08:19 2014
@@ -133,15 +133,14 @@ public class SolrQueryIndex implements F
                                     int mltFlIndex = parameterString.indexOf(mltFlString);
                                     if (mltFlIndex > -1) {
                                         int beginIndex = mltFlIndex + mltFlString.length();
-                                        int endIndex = parameterString.indexOf('&',beginIndex);
+                                        int endIndex = parameterString.indexOf('&', beginIndex);
                                         String fields;
                                         if (endIndex > beginIndex) {
                                             fields = parameterString.substring(beginIndex,
endIndex);
-                                        }
-                                        else {
+                                        } else {
                                             fields = parameterString.substring(beginIndex);
                                         }
-                                        kv[1] = "_query_:\"{!dismax qf="+fields+" q.op=OR}"+kv[1]+"\"";
+                                        kv[1] = "_query_:\"{!dismax qf=" + fields + " q.op=OR}"
+ kv[1] + "\"";
                                     }
                                 }
                                 solrQuery.setParam(kv[0], kv[1]);
@@ -258,9 +257,7 @@ public class SolrQueryIndex implements F
                     }
                     FullTextExpression e = or.list.get(i);
                     String orTerm = getFullTextQuery(e);
-                    fullTextString.append('(');
                     fullTextString.append(orTerm);
-                    fullTextString.append(')');
                 }
                 fullTextString.append(')');
                 fullTextString.append(' ');
@@ -276,9 +273,7 @@ public class SolrQueryIndex implements F
                     }
                     FullTextExpression e = and.list.get(i);
                     String andTerm = getFullTextQuery(e);
-                    fullTextString.append('(');
                     fullTextString.append(andTerm);
-                    fullTextString.append(')');
                 }
                 fullTextString.append(')');
                 fullTextString.append(' ');
@@ -299,7 +294,14 @@ public class SolrQueryIndex implements F
                 }
                 fullTextString.append(p);
                 fullTextString.append(':');
-                fullTextString.append(partialEscape(term.getText()));
+                String termText = term.getText();
+                if (termText.indexOf(' ') > 0) {
+                    fullTextString.append('"');
+                }
+                fullTextString.append(termText.replace("/", "\\/").replace(":", "\\:"));
+                if (termText.indexOf(' ') > 0) {
+                    fullTextString.append('"');
+                }
                 String boost = term.getBoost();
                 if (boost != null) {
                     fullTextString.append('^');

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml Mon Apr
 7 14:08:19 2014
@@ -131,7 +131,7 @@
 
     <dynamicField name="*_pi"  type="pint"    indexed="true"  stored="true"/>
     <dynamicField name="*_c"   type="currency" indexed="true"  stored="true"/>
-    <dynamicField name="*" type="text_keepcase" indexed="true" stored="true" multiValued="true"/>
+    <dynamicField name="*" type="text_general" indexed="true" stored="true" multiValued="true"/>
   </fields>
   <uniqueKey>path_exact</uniqueKey>
   <copyField source="path_exact" dest="path_anc"/>

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/SolrOakRepositoryStub.java
Mon Apr  7 14:08:19 2014
@@ -21,8 +21,11 @@ import java.util.Properties;
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.oak.plugins.index.aggregate.AggregateIndexProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.CommitPolicy;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.EmbeddedSolrServerConfiguration;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration;
 import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
@@ -54,7 +57,20 @@ public class SolrOakRepositoryStub exten
                 return solrServer;
             }
         };
-        OakSolrConfigurationProvider oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider();
+        try {
+            // safely remove any previous document on the index
+            solrServer.deleteByQuery("*:*");
+            solrServer.commit();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        OakSolrConfiguration configuration = new DefaultSolrConfiguration() {
+            @Override
+            public CommitPolicy getCommitPolicy() {
+                return CommitPolicy.HARD;
+            }
+        };
+        OakSolrConfigurationProvider oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider(configuration);
         jcr.with(new SolrIndexInitializer(false))
                 .with(AggregateIndexProvider.wrap(new SolrQueryIndexProvider(solrServerProvider,
oakSolrConfigurationProvider)))
                 .with(new SolrIndexEditorProvider(solrServerProvider, oakSolrConfigurationProvider));

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/jcr/query/QueryJcrTest.java
Mon Apr  7 14:08:19 2014
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.jcr.qu
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+import org.apache.jackrabbit.core.query.FulltextQueryTest;
+import org.apache.jackrabbit.core.query.JoinTest;
 import org.apache.jackrabbit.core.query.LimitAndOffsetTest;
 import org.apache.jackrabbit.core.query.PathQueryNodeTest;
 import org.apache.jackrabbit.core.query.SQL2OffsetLimitTest;
@@ -36,7 +38,7 @@ public class QueryJcrTest extends TestCa
     public static Test suite() {
         TestSuite suite = new ConcurrentTestSuite(
                 "Jackrabbit query tests using a Solr based index");
-//        suite.addTestSuite(FulltextQueryTest.class); // fail
+        suite.addTestSuite(FulltextQueryTest.class);
         suite.addTestSuite(SQLTest.class);
 //        suite.addTestSuite(JoinTest.class); // fail
         suite.addTestSuite(SkipDeletedNodesTest.class);

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTest.java
Mon Apr  7 14:08:19 2014
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.oak.plugins.index.solr.query;
 
 import java.util.Iterator;
+
+import com.google.common.collect.ImmutableList;
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -72,11 +74,11 @@ public class SolrIndexQueryTest extends 
                     .with(new CompositeQueryIndexProvider(
                             new SolrQueryIndexProvider(provider, provider),
                             new PropertyIndexProvider()
-                            ))
+                    ))
                     .with(new CompositeIndexEditorProvider(
                             new SolrIndexEditorProvider(provider, provider),
                             new PropertyIndexEditorProvider()
-                            ))
+                    ))
                     .createContentRepository();
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -275,4 +277,12 @@ public class SolrIndexQueryTest extends 
         test("native_solr.txt");
     }
 
+    @Test
+    public void testTokenizeCN() throws Exception {
+        Tree t = root.getTree("/").addChild("containsCN");
+        Tree one = t.addChild("one");
+        one.setProperty("t", "美女衬衫");
+        root.commit();
+        assertQuery("//*[jcr:contains(., '美女')]", "xpath", ImmutableList.of(one.getPath()));
+    }
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/schema.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/schema.xml?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/schema.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/schema.xml Mon Apr
 7 14:08:19 2014
@@ -141,7 +141,7 @@
 
         <dynamicField name="*_pi"  type="pint"    indexed="true"  stored="true"/>
         <dynamicField name="*_c"   type="currency" indexed="true"  stored="true"/>
-        <dynamicField name="*" type="text_keepcase" indexed="true" stored="true" multiValued="true"/>
+        <dynamicField name="*" type="text_general" indexed="true" stored="true" multiValued="true"/>
     </fields>
     <uniqueKey>path_exact</uniqueKey>
     <copyField source="path_exact" dest="path_anc"/>

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/solrconfig.xml?rev=1585486&r1=1585485&r2=1585486&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/solrconfig.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/resources/solr/oak/conf/solrconfig.xml Mon
Apr  7 14:08:19 2014
@@ -35,7 +35,7 @@
          that you fully re-index after changing this setting as it can
          affect both how text is indexed and queried.
     -->
-    <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
+    <luceneMatchVersion>LUCENE_47</luceneMatchVersion>
 
     <!-- lib directives can be used to instruct Solr to load an Jars
        identified and use them to resolve any "plugins" specified in



Mime
View raw message