jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1574838 - in /jackrabbit/oak/trunk/oak-solr-core/src: main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/ main/resources/solr/oak/conf/ test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/ test/resources/solr/oak/conf/
Date Thu, 06 Mar 2014 10:29:34 GMT
Author: tommaso
Date: Thu Mar  6 10:29:34 2014
New Revision: 1574838

URL: http://svn.apache.org/r1574838
Log:
OAK-1286 - added missing tests for MLT feature in Solr

Modified:
    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/solrconfig.xml
    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/solrconfig.xml

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=1574838&r1=1574837&r2=1574838&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
Thu Mar  6 10:29:34 2014
@@ -100,7 +100,7 @@ public class SolrQueryIndex implements F
                 // native query support
                 if (NATIVE_SOLR_QUERY.equals(pr.propertyName)) {
                     String nativeQueryString = String.valueOf(pr.first.getValue(pr.first.getType()));
-                    if (isHttpRequest(nativeQueryString)) {
+                    if (isSupportedHttpRequest(nativeQueryString)) {
                         // pass through the native HTTP Solr request
                         String requestHandlerString = nativeQueryString.substring(0, nativeQueryString.indexOf('?'));
                         if (!"select".equals(requestHandlerString)) {
@@ -206,7 +206,7 @@ public class SolrQueryIndex implements F
         return solrQuery;
     }
 
-    private boolean isHttpRequest(String nativeQueryString) {
+    private boolean isSupportedHttpRequest(String nativeQueryString) {
         // the query string starts with ${supported-handler.selector}?
         return nativeQueryString.matches("(mlt|query|select|get)\\\\?.*");
     }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml?rev=1574838&r1=1574837&r2=1574838&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml Thu
Mar  6 10:29:34 2014
@@ -235,6 +235,9 @@
     </arr>
   </requestHandler>
 
+    <requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
+    </requestHandler>
+
 
   <searchComponent name="terms" class="solr.TermsComponent"/>
 

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=1574838&r1=1574837&r2=1574838&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
Thu Mar  6 10:29:34 2014
@@ -202,7 +202,7 @@ public class SolrIndexQueryTest extends 
     }
 
     @Test
-     public void testNativeSolrNestedQuery() throws Exception {
+    public void testNativeSolrNestedQuery() throws Exception {
         String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr',
'_query_:\"{!dismax qf=catch_all q.op=OR}hello world\"')";
 
         Tree tree = root.getTree("/");
@@ -221,6 +221,25 @@ public class SolrIndexQueryTest extends 
     }
 
     @Test
+    public void testNativeMLTQuery() throws Exception {
+        String nativeQueryString = "select [jcr:path] from [nt:base] where native('solr',
'mlt?q=name:World&mlt.fl=name&mlt.mindf=0&mlt.mintf=0')";
+
+        Tree tree = root.getTree("/");
+        Tree test = tree.addChild("test");
+        test.addChild("a").setProperty("name", "Hello World, today weather is nice");
+        test.addChild("b").setProperty("name", "Cheers World, today weather is quite nice");
+        tree.addChild("c");
+        root.commit();
+
+        Iterator<String> strings = executeQuery(nativeQueryString, "JCR-SQL2").iterator();
+        assertTrue(strings.hasNext());
+        assertEquals("/test/a", strings.next());
+        assertTrue(strings.hasNext());
+        assertEquals("/test/b", strings.next());
+        assertFalse(strings.hasNext());
+    }
+
+    @Test
     public void nativeSolr() throws Exception {
         test("native_solr.txt");
     }

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=1574838&r1=1574837&r2=1574838&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 Thu
Mar  6 10:29:34 2014
@@ -1331,6 +1331,9 @@ current implementation relies on the upd
         </arr>
     </requestHandler>
 
+    <requestHandler name="/mlt" class="solr.MoreLikeThisHandler">
+    </requestHandler>
+
     <!-- Clustering Component
 
        http://wiki.apache.org/solr/ClusteringComponent



Mime
View raw message