You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by to...@apache.org on 2015/07/16 14:50:21 UTC
svn commit: r1691385 -
/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java
Author: tommaso
Date: Thu Jul 16 12:50:20 2015
New Revision: 1691385
URL: http://svn.apache.org/r1691385
Log:
OAK-3101 - added IT from Davide
Modified:
jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java
Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java?rev=1691385&r1=1691384&r2=1691385&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java (original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrIndexQueryTestIT.java Thu Jul 16 12:50:20 2015
@@ -20,15 +20,16 @@ import java.util.Iterator;
import com.google.common.collect.ImmutableList;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.Oak;
import org.apache.jackrabbit.oak.api.ContentRepository;
import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.index.CompositeIndexEditorProvider;
import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider;
import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider;
import org.apache.jackrabbit.oak.plugins.index.solr.TestUtils;
import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
-import org.apache.jackrabbit.oak.plugins.index.solr.util.SolrIndexInitializer;
import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
import org.apache.jackrabbit.oak.query.AbstractQueryTest;
import org.apache.jackrabbit.oak.spi.query.CompositeQueryIndexProvider;
@@ -38,6 +39,8 @@ import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
+import javax.jcr.query.Query;
+
import static java.util.Arrays.asList;
import static junit.framework.Assert.assertEquals;
import static org.apache.jackrabbit.oak.api.Type.STRINGS;
@@ -71,7 +74,6 @@ public class SolrIndexQueryTestIT extend
solrServer = provider.getSolrServer();
try {
return new Oak().with(new InitialContent())
- .with(new SolrIndexInitializer())
.with(new OpenSecurityProvider())
.with(new CompositeQueryIndexProvider(
new SolrQueryIndexProvider(provider, provider),
@@ -492,4 +494,32 @@ public class SolrIndexQueryTestIT extend
assertEquals("/test/b", result.next());
assertFalse(result.hasNext());
}
+
+ @Test
+ public void testOrderByJcrScore() throws Exception {
+ Tree index = root.getTree("/oak:index/" + TEST_INDEX_NAME);
+ assertTrue(index.exists());
+
+ index.setProperty("pathRestrictions", true);
+ index.setProperty("rows", 10000);
+ index.setProperty("reindex", true);
+ root.commit();
+
+ Tree content = root.getTree("/").addChild("content");
+ Tree a = content.addChild("a");
+ a.setProperty(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED, Type.NAME);
+ a.setProperty("type", "doc doc doc");
+ root.commit();
+
+ String statement = "select [jcr:path], [jcr:score], [rep:excerpt] " +
+ "from [nt:unstructured] as a " +
+ "where contains(*, 'doc') " +
+ "and isdescendantnode(a, '/content') " +
+ "order by [jcr:score] desc";
+
+ Iterator<String> results = executeQuery(statement, Query.JCR_SQL2, true).iterator();
+ assertTrue(results.hasNext());
+ assertEquals("/content/a", results.next());
+ assertFalse(results.hasNext());
+ }
}