Author: chetanm
Date: Mon Feb 16 12:47:26 2015
New Revision: 1660099
URL: http://svn.apache.org/r1660099
Log:
OAK-2524 - Error while configuring analyzer by composition
Add jcr:primaryType to ignore list. All nodes created via JCR Api would have
this property set and this should not be passed to Lucene
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java
Modified:
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java?rev=1660099&r1=1660098&r2=1660099&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
(original)
+++
jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java
Mon Feb 16 12:47:26 2015
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.Atomi
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Tree;
@@ -67,7 +68,11 @@ import static com.google.common.collect.
final class NodeStateAnalyzerFactory{
private static final AtomicBoolean versionWarningAlreadyLogged = new
AtomicBoolean(false);
- private static final Set<String> IGNORE_PROP_NAMES =
ImmutableSet.of(LuceneIndexConstants.ANL_CLASS, LuceneIndexConstants.ANL_NAME);
+ private static final Set<String> IGNORE_PROP_NAMES = ImmutableSet.of(
+ LuceneIndexConstants.ANL_CLASS,
+ LuceneIndexConstants.ANL_NAME,
+ JcrConstants.JCR_PRIMARYTYPE
+ );
private static final Logger log =
LoggerFactory.getLogger(NodeStateAnalyzerFactory.class);
Modified:
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java?rev=1660099&r1=1660098&r2=1660099&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java
(original)
+++
jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactoryTest.java
Mon Feb 16 12:47:26 2015
@@ -27,6 +27,7 @@ import java.util.Map;
import com.google.common.collect.ImmutableList;
import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.JcrConstants;
import
org.apache.jackrabbit.oak.plugins.index.lucene.NodeStateAnalyzerFactory.NodeStateResourceLoader;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.TokenizerChain;
import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
@@ -45,6 +46,7 @@ import org.junit.Test;
import static org.apache.jackrabbit.JcrConstants.JCR_CONTENT;
import static org.apache.jackrabbit.JcrConstants.JCR_DATA;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
import static org.apache.jackrabbit.oak.api.Type.NAMES;
import static
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANL_CHAR_FILTERS;
import static
org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANL_CLASS;
@@ -57,6 +59,7 @@ import static org.apache.jackrabbit.oak.
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class NodeStateAnalyzerFactoryTest {
@@ -107,6 +110,7 @@ public class NodeStateAnalyzerFactoryTes
NodeBuilder filters = nb.child(ANL_FILTERS);
filters.setProperty(OAK_CHILD_ORDER, ImmutableList.of("stop",
"LowerCase"),NAMES);
filters.child("LowerCase").setProperty(ANL_NAME, "LowerCase");
+ filters.child("LowerCase").setProperty(JCR_PRIMARYTYPE,
"nt:unstructured");
//name is optional. Derived from nodeName
filters.child("stop").setProperty(ANL_LUCENE_MATCH_VERSION,
Version.LUCENE_31.toString());
@@ -177,10 +181,12 @@ public class NodeStateAnalyzerFactoryTes
NodeBuilder nb = EMPTY_NODE.builder();
nb.setProperty("a", "a");
nb.setProperty("b", 1);
+ nb.setProperty(JcrConstants.JCR_PRIMARYTYPE, "nt:base");
Map<String, String> result =
factory.convertNodeState(nb.getNodeState());
assertEquals("a", result.get("a"));
assertEquals("1", result.get("b"));
+ assertNull(result.get(JcrConstants.JCR_PRIMARYTYPE));
}
private static NodeBuilder createFileNode(NodeBuilder nb, String nodeName,
byte[] content){