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 ca...@apache.org on 2018/02/22 22:07:44 UTC
svn commit: r1825101 - in /jackrabbit/oak/branches/1.8: ./
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/
oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/
Author: catholicon
Date: Thu Feb 22 22:07:44 2018
New Revision: 1825101
URL: http://svn.apache.org/viewvc?rev=1825101&view=rev
Log:
AK-7198: Index rule with REGEX_ALL_PROPS includes relative node
(backport r1822121, r1822201 and r1822808 from trunk)
Modified:
jackrabbit/oak/branches/1.8/ (props changed)
jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/PropertyDefinition.java
jackrabbit/oak/branches/1.8/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinitionTest.java
Propchange: jackrabbit/oak/branches/1.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 22 22:07:44 2018
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1820660-1820661,1820729,1820734,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141,1821240,1821249,1821258,1821325,1821358,1821361-1821362,1821370,1821375,1821393,1821477,1821487,1821516,1821665,1821668,1821681,1822723,1822850,1822934,1823135,1823163,1823169,1824962
+/jackrabbit/oak/trunk:1820660-1820661,1820729,1820734,1820859,1820861,1820878,1820888,1820947,1821130,1821140-1821141,1821240,1821249,1821258,1821325,1821358,1821361-1821362,1821370,1821375,1821393,1821477,1821487,1821516,1821665,1821668,1821681,1822121,1822201,1822723,1822808,1822850,1822934,1823135,1823163,1823169,1824962
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java?rev=1825101&r1=1825100&r2=1825101&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java (original)
+++ jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinition.java Thu Feb 22 22:07:44 2018
@@ -1521,13 +1521,13 @@ public final class IndexDefinition imple
if (propName.equals(includeAllProp)){
prop.setProperty(LuceneIndexConstants.PROP_IS_REGEX, true);
- }
-
- //Copy over the property configuration
- NodeState propDefNode = getPropDefnNode(defn, propName);
- if (propDefNode != null){
- for (PropertyState ps : propDefNode.getProperties()){
- prop.setProperty(ps);
+ } else {
+ //Copy over the property configuration
+ NodeState propDefNode = getPropDefnNode(defn, propName);
+ if (propDefNode != null){
+ for (PropertyState ps : propDefNode.getProperties()){
+ prop.setProperty(ps);
+ }
}
}
}
Modified: jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/PropertyDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/PropertyDefinition.java?rev=1825101&r1=1825100&r2=1825101&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/PropertyDefinition.java (original)
+++ jackrabbit/oak/branches/1.8/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/PropertyDefinition.java Thu Feb 22 22:07:44 2018
@@ -44,6 +44,9 @@ import static org.apache.jackrabbit.oak.
public class PropertyDefinition {
private static final Logger log = LoggerFactory.getLogger(PropertyDefinition.class);
+
+ private static final String[] EMPTY_ANCESTORS = new String[0];
+
/**
* The default boost: 1.0f.
*/
@@ -232,7 +235,9 @@ public class PropertyDefinition {
}
static boolean isRelativeProperty(String propertyName){
- return !isAbsolute(propertyName) && PathUtils.getNextSlash(propertyName, 0) > 0;
+ return !isAbsolute(propertyName)
+ && !LuceneIndexConstants.REGEX_ALL_PROPS.equals(propertyName)
+ && PathUtils.getNextSlash(propertyName, 0) > 0;
}
//~---------------------------------------------< internal >
@@ -265,8 +270,12 @@ public class PropertyDefinition {
return PathUtils.getName(name);
}
- private static String[] computeAncestors(String parentPath) {
- return toArray(copyOf(elements(PathUtils.getParentPath(parentPath))), String.class);
+ private static String[] computeAncestors(String path) {
+ if (LuceneIndexConstants.REGEX_ALL_PROPS.equals(path)) {
+ return EMPTY_ANCESTORS;
+ } else {
+ return toArray(copyOf(elements(PathUtils.getParentPath(path))), String.class);
+ }
}
Modified: jackrabbit/oak/branches/1.8/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinitionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinitionTest.java?rev=1825101&r1=1825100&r2=1825101&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.8/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinitionTest.java (original)
+++ jackrabbit/oak/branches/1.8/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexDefinitionTest.java Thu Feb 22 22:07:44 2018
@@ -20,6 +20,7 @@
package org.apache.jackrabbit.oak.plugins.index.lucene;
import java.util.Collections;
+import java.util.List;
import javax.jcr.PropertyType;
@@ -65,6 +66,8 @@ import static org.apache.jackrabbit.oak.
import static org.apache.jackrabbit.oak.InitialContent.INITIAL_CONTENT;
import static org.apache.jackrabbit.oak.plugins.tree.TreeConstants.OAK_CHILD_ORDER;
import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -1196,6 +1199,35 @@ public class IndexDefinitionTest {
assertTrue(defn.indexesRelativeNodes());
}
+ @Test
+ public void regexAllProps() {
+ IndexDefinitionBuilder builder = new IndexDefinitionBuilder();
+ builder.indexRule("nt:base").property("p");
+ builder.indexRule("nt:base").property("all", LuceneIndexConstants.REGEX_ALL_PROPS, true);
+
+ IndexDefinition def = IndexDefinition.newBuilder(root, builder.build(), "/foo").build();
+ IndexingRule rule = def.getApplicableIndexingRule(root);
+ assertNotNull(rule);
+
+ PropertyDefinition pd = rule.getConfig("p");
+ assertNotNull(pd);
+ assertFalse(pd.isRegexp);
+ assertFalse(pd.relative);
+ assertEquals(0, pd.ancestors.length);
+
+ pd = rule.getConfig("all");
+ assertNotNull(pd);
+ assertTrue(pd.isRegexp);
+ assertFalse(pd.relative);
+ assertEquals(0, pd.ancestors.length);
+
+ assertThat(rule.getAggregate().getIncludes(), is(empty()));
+ assertFalse(rule.getAggregate().hasNodeAggregates());
+ List<Aggregate.Matcher> matchers = rule.getAggregate()
+ .createMatchers(new TestRoot("/"));
+ assertThat(matchers, is(empty()));
+ assertThat(def.getRelativeNodeNames(), is(empty()));
+ }
//TODO indexesAllNodesOfMatchingType - with nullCheckEnabled
@@ -1220,4 +1252,21 @@ public class IndexDefinitionTest {
return builder;
}
+ private static class TestRoot implements Aggregate.AggregateRoot {
+
+ private final String path;
+
+ public TestRoot(String path) {
+ this.path = path;
+ }
+
+ @Override
+ public void markDirty() {
+ }
+
+ @Override
+ public String getPath() {
+ return path;
+ }
+ }
}