Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java Tue Sep 25 12:24:15 2018 @@ -16,7 +16,16 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene; -import com.google.common.collect.ImmutableList; +import static com.google.common.collect.ImmutableList.of; +import static java.util.Arrays.asList; +import static junit.framework.Assert.assertEquals; +import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; +import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; +import static org.apache.jackrabbit.oak.api.Type.STRING; +import static org.apache.jackrabbit.oak.api.Type.STRINGS; +import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.useV2; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Iterator; @@ -27,6 +36,7 @@ import org.apache.jackrabbit.oak.api.Con import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.InitialContentHelper; import org.apache.jackrabbit.oak.query.AbstractQueryTest; @@ -37,16 +47,7 @@ import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; -import static com.google.common.collect.ImmutableList.of; -import static java.util.Arrays.asList; -import static junit.framework.Assert.assertEquals; -import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE; -import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED; -import static org.apache.jackrabbit.oak.api.Type.STRING; -import static org.apache.jackrabbit.oak.api.Type.STRINGS; -import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.useV2; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import com.google.common.collect.ImmutableList; /** * Tests the query engine using the default index implementation: the @@ -60,12 +61,12 @@ public class LuceneIndexQueryTest extend Tree indexDefn = createTestIndexNode(index, LuceneIndexConstants.TYPE_LUCENE); useV2(indexDefn); indexDefn.setProperty(LuceneIndexConstants.TEST_MODE, true); - indexDefn.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true); + indexDefn.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); Tree props = TestUtil.newRulePropTree(indexDefn, "nt:base"); - props.getParent().setProperty(LuceneIndexConstants.INDEX_NODE_NAME, true); + props.getParent().setProperty(FulltextIndexConstants.INDEX_NODE_NAME, true); TestUtil.enablePropertyIndex(props, "c1/p", false); - TestUtil.enableForFullText(props, LuceneIndexConstants.REGEX_ALL_PROPS, true); + TestUtil.enableForFullText(props, FulltextIndexConstants.REGEX_ALL_PROPS, true); TestUtil.enablePropertyIndex(props, "a/name", false); TestUtil.enablePropertyIndex(props, "b/name", false); TestUtil.enableFunctionIndex(props, "length([name])"); @@ -112,8 +113,8 @@ public class LuceneIndexQueryTest extend root.commit(); Iterator<String> result = executeQuery( - "select [jcr:path] from [nt:base] where isdescendantnode('/test')", - "JCR-SQL2").iterator(); + "select [jcr:path] from [nt:base] where isdescendantnode('/test')", + "JCR-SQL2").iterator(); assertTrue(result.hasNext()); assertEquals("/test/a", result.next()); assertEquals("/test/b", result.next()); @@ -128,8 +129,8 @@ public class LuceneIndexQueryTest extend root.commit(); Iterator<String> result = executeQuery( - "select [jcr:path] from [nt:base] where isdescendantnode('/test') and name='World'", - "JCR-SQL2").iterator(); + "select [jcr:path] from [nt:base] where isdescendantnode('/test') and name='World'", + "JCR-SQL2").iterator(); assertTrue(result.hasNext()); assertEquals("/test/a", result.next()); assertFalse(result.hasNext()); @@ -150,8 +151,8 @@ public class LuceneIndexQueryTest extend root.commit(); Iterator<String> result = executeQuery( - "select p.[jcr:path], p2.[jcr:path] from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path] = '/'", - "JCR-SQL2").iterator(); + "select p.[jcr:path], p2.[jcr:path] from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path] = '/'", + "JCR-SQL2").iterator(); assertTrue(result.hasNext()); assertEquals("/, /children", result.next()); assertEquals("/, /jcr:system", result.next()); @@ -175,7 +176,7 @@ public class LuceneIndexQueryTest extend stmt.append("/jcr:root//*[jcr:contains(., '").append(h); stmt.append("')]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of("/test/a", "/test/b")); + ImmutableList.of("/test/a", "/test/b")); // query 'world' stmt = new StringBuffer(); @@ -197,34 +198,34 @@ public class LuceneIndexQueryTest extend String planPrefix = "[nt:base] as [a] /* lucene:test-index(/oak:index/test-index) "; assertXPathPlan("/jcr:root//*[@a]", - planPrefix + "a:[* TO *]"); + planPrefix + "a:[* TO *]"); assertXPathPlan("/jcr:root//*[jcr:contains(., '*')]", - planPrefix + ":fulltext:* ft:(\"*\")"); + planPrefix + ":fulltext:* ft:(\"*\")"); assertXPathPlan("/jcr:root//*[jcr:contains(@a,'*')]", - planPrefix + "full:a:* ft:(a:\"*\")"); + planPrefix + "full:a:* ft:(a:\"*\")"); assertXPathPlan("/jcr:root//*[jcr:contains(@a,'hello -world')]", - planPrefix + "+full:a:hello -full:a:world ft:(a:\"hello\" -a:\"world\")"); + planPrefix + "+full:a:hello -full:a:world ft:(a:\"hello\" -a:\"world\")"); assertXPathPlan("/jcr:root//*[jcr:contains(@a,'test*')]", - planPrefix + "full:a:test* ft:(a:\"test*\")"); + planPrefix + "full:a:test* ft:(a:\"test*\")"); assertXPathPlan("/jcr:root//*[jcr:contains(@a,'-test')]", - planPrefix + "-full:a:test *:* ft:(-a:\"test\")"); + planPrefix + "-full:a:test *:* ft:(-a:\"test\")"); assertXPathPlan("/jcr:root//*[jcr:contains(@a,'-test*')]", - planPrefix + "-full:a:test* *:* ft:(-a:\"test*\")"); + planPrefix + "-full:a:test* *:* ft:(-a:\"test*\")"); assertXPathPlan("/jcr:root//*[jcr:contains(., '-*')]", - planPrefix + "-:fulltext:* *:* ft:(-\"*\")"); + planPrefix + "-:fulltext:* *:* ft:(-\"*\")"); assertXPathPlan("/jcr:root//*[jcr:contains(., 'apple - pear')]", - planPrefix + "+:fulltext:apple -:fulltext:pear ft:(\"apple\" \"-\" \"pear\")"); + planPrefix + "+:fulltext:apple -:fulltext:pear ft:(\"apple\" \"-\" \"pear\")"); assertXPathPlan("/jcr:root/content//*[jcr:contains(., 'apple - pear')]", - planPrefix + "-:fulltext:pear +:fulltext:apple +:ancestors:/content ft:(\"apple\" \"-\" \"pear\")"); + planPrefix + "-:fulltext:pear +:fulltext:apple +:ancestors:/content ft:(\"apple\" \"-\" \"pear\")"); } @@ -247,9 +248,9 @@ public class LuceneIndexQueryTest extend root.commit(); assertQuery("/jcr:root//*[jcr:contains(., 'hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + ImmutableList.of("/test/a", "/test/b")); assertQuery("/jcr:root//*[jcr:contains(., '*hello-wor*')]", "xpath", - ImmutableList.of("/test/a", "/test/b")); + ImmutableList.of("/test/a", "/test/b")); } @@ -262,13 +263,13 @@ public class LuceneIndexQueryTest extend root.commit(); assertQuery( - "/jcr:root//*[jcr:contains(@dc:format, 'pro*')]", - "xpath", ImmutableList.of("/test/b")); + "/jcr:root//*[jcr:contains(@dc:format, 'pro*')]", + "xpath", ImmutableList.of("/test/b")); assertQuery( - "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]", - "xpath", ImmutableList.of("/test/a")); + "/jcr:root//*[jcr:contains(@dc:format, 'type:appli*')]", + "xpath", ImmutableList.of("/test/a")); } @@ -308,7 +309,7 @@ public class LuceneIndexQueryTest extend StringBuffer stmt = new StringBuffer(); stmt.append("//*[jcr:contains(., 'match')]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of("/match_on_path")); + ImmutableList.of("/match_on_path")); } @@ -321,7 +322,7 @@ public class LuceneIndexQueryTest extend StringBuffer stmt = new StringBuffer(); stmt.append("//*[jcr:contains(., 'match')]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of("/match_on_path1234")); + ImmutableList.of("/match_on_path1234")); } @@ -348,7 +349,7 @@ public class LuceneIndexQueryTest extend StringBuffer stmt = new StringBuffer(); stmt.append("//*[jcr:contains(., 'media') and (@p = 'dam/smartcollection' or @p = 'dam/collection') ]"); assertQuery(stmt.toString(), "xpath", - ImmutableList.of(one.getPath(), two.getPath())); + ImmutableList.of(one.getPath(), two.getPath())); } @Test @@ -368,7 +369,7 @@ public class LuceneIndexQueryTest extend @Test public void testRepSimilarAsNativeQuery() throws Exception { String nativeQueryString = "select [jcr:path] from [nt:base] where " + - "native('lucene', 'mlt?stream.body=/test/a&mlt.fl=:path&mlt.mindf=0&mlt.mintf=0')"; + "native('lucene', 'mlt?stream.body=/test/a&mlt.fl=:path&mlt.mindf=0&mlt.mintf=0')"; Tree test = root.getTree("/").addChild("test"); test.addChild("a").setProperty("text", "Hello World"); test.addChild("b").setProperty("text", "He said Hello and then the world said Hello as well."); @@ -430,7 +431,7 @@ public class LuceneIndexQueryTest extend one.setProperty("t", "ç¾å¥³è¡¬è¡«"); root.commit(); assertQuery("//*[jcr:contains(., 'ç¾å¥³')]", "xpath", - ImmutableList.of(one.getPath())); + ImmutableList.of(one.getPath())); } @Test @@ -441,8 +442,8 @@ public class LuceneIndexQueryTest extend test.addChild(child).setProperty(mulValuedProp, of("foo","bar"), Type.STRINGS); root.commit(); assertQuery( - "/jcr:root//*[jcr:contains(@" + mulValuedProp + ", 'foo')]", - "xpath", of("/test/" + child)); + "/jcr:root//*[jcr:contains(@" + mulValuedProp + ", 'foo')]", + "xpath", of("/test/" + child)); test.getChild(child).setProperty(mulValuedProp, new ArrayList<String>(), Type.STRINGS); root.commit(); assertQuery("/jcr:root//*[jcr:contains(@" + mulValuedProp + ", 'foo')]", "xpath", new ArrayList<String>()); @@ -450,8 +451,8 @@ public class LuceneIndexQueryTest extend test.getChild(child).setProperty(mulValuedProp, of("bar"), Type.STRINGS); root.commit(); assertQuery( - "/jcr:root//*[jcr:contains(@" + mulValuedProp + ", 'foo')]", - "xpath", new ArrayList<String>()); + "/jcr:root//*[jcr:contains(@" + mulValuedProp + ", 'foo')]", + "xpath", new ArrayList<String>()); test.getChild(child).removeProperty(mulValuedProp); root.commit();
Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionTest.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexSuggestionTest.java Tue Sep 25 12:24:15 2018 @@ -20,8 +20,8 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_RULES; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.shutdown; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INDEX_RULES; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -44,6 +44,8 @@ import org.apache.jackrabbit.JcrConstant import org.apache.jackrabbit.api.JackrabbitSession; import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils; import org.apache.jackrabbit.oak.jcr.Jcr; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.index.search.IndexFormatVersion; import org.apache.jackrabbit.oak.spi.commit.Observer; import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; import org.junit.After; @@ -68,9 +70,9 @@ public class LuceneIndexSuggestionTest { LuceneIndexProvider provider = new LuceneIndexProvider(); Jcr jcr = new Jcr() - .with(((QueryIndexProvider) provider)) - .with((Observer) provider) - .with(new LuceneIndexEditorProvider()); + .with(((QueryIndexProvider) provider)) + .with((Observer) provider) + .with(new LuceneIndexEditorProvider()); repository = jcr.createRepository(); session = (JackrabbitSession) repository.login(new SimpleCredentials("admin", "admin".toCharArray())); @@ -84,27 +86,27 @@ public class LuceneIndexSuggestionTest { } private void createSuggestIndex(String name, String indexedNodeType, String indexedPropertyName) - throws Exception { + throws Exception { createSuggestIndex(name, indexedNodeType, indexedPropertyName, false, false); } private void createSuggestIndex(String name, String indexedNodeType, String indexedPropertyName, boolean addFullText, boolean suggestAnalyzed) - throws Exception { + throws Exception { Node def = root.getNode(INDEX_DEFINITIONS_NAME) - .addNode(name, INDEX_DEFINITIONS_NODE_TYPE); + .addNode(name, INDEX_DEFINITIONS_NODE_TYPE); def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); def.setProperty(REINDEX_PROPERTY_NAME, true); def.setProperty("name", name); - def.setProperty(LuceneIndexConstants.COMPAT_MODE, IndexFormatVersion.V2.getVersion()); + def.setProperty(FulltextIndexConstants.COMPAT_MODE, IndexFormatVersion.V2.getVersion()); if (suggestAnalyzed) { - def.addNode(LuceneIndexConstants.SUGGESTION_CONFIG).setProperty("suggestAnalyzed", suggestAnalyzed); + def.addNode(FulltextIndexConstants.SUGGESTION_CONFIG).setProperty("suggestAnalyzed", suggestAnalyzed); } Node propertyIdxDef = def.addNode(INDEX_RULES, JcrConstants.NT_UNSTRUCTURED) - .addNode(indexedNodeType, JcrConstants.NT_UNSTRUCTURED) - .addNode(LuceneIndexConstants.PROP_NODE, JcrConstants.NT_UNSTRUCTURED) - .addNode("indexedProperty", JcrConstants.NT_UNSTRUCTURED); + .addNode(indexedNodeType, JcrConstants.NT_UNSTRUCTURED) + .addNode(FulltextIndexConstants.PROP_NODE, JcrConstants.NT_UNSTRUCTURED) + .addNode("indexedProperty", JcrConstants.NT_UNSTRUCTURED); propertyIdxDef.setProperty("propertyIndex", true); propertyIdxDef.setProperty("analyzed", true); propertyIdxDef.setProperty("useInSuggest", true); @@ -122,11 +124,11 @@ public class LuceneIndexSuggestionTest { final String indexPropName, final String indexPropValue, final boolean addFullText, final boolean useUserSession, final String suggestQueryText, final boolean shouldSuggest, final boolean suggestAnalyzed) - throws Exception { + throws Exception { checkSuggestions(nodeType, nodeType, - indexPropName, indexPropValue, - addFullText, useUserSession, - suggestQueryText, shouldSuggest, suggestAnalyzed); + indexPropName, indexPropValue, + addFullText, useUserSession, + suggestQueryText, shouldSuggest, suggestAnalyzed); } /** @@ -138,7 +140,7 @@ public class LuceneIndexSuggestionTest { final boolean addFullText, final boolean useUserSession, final String suggestQueryText, final boolean shouldSuggest, final boolean suggestAnalyzed) - throws Exception { + throws Exception { createSuggestIndex("lucene-suggest", indexNodeType, indexPropName, addFullText, suggestAnalyzed); Node indexedNode = root.addNode("indexedNode1", queryNodeType); @@ -191,7 +193,7 @@ public class LuceneIndexSuggestionTest { public void suggestNodeName() throws Exception { final String nodeType = "nt:unstructured"; - createSuggestIndex("lucene-suggest", nodeType, LuceneIndexConstants.PROPDEF_PROP_NODE_NAME); + createSuggestIndex("lucene-suggest", nodeType, FulltextIndexConstants.PROPDEF_PROP_NODE_NAME); root.addNode("indexedNode", nodeType); session.save(); @@ -221,9 +223,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = true; checkSuggestions(nodeType, - indexPropName, indexPropValue, - false, false, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + false, false, + suggestQueryText, shouldSuggest, false); } //OAK-4126 @@ -236,9 +238,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = true; checkSuggestions(nodeType, - indexPropName, indexPropValue, - false, false, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + false, false, + suggestQueryText, shouldSuggest, false); } @Test @@ -279,9 +281,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = true; checkSuggestions(nodeType, - indexPropName, indexPropValue, - false, true, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + false, true, + suggestQueryText, shouldSuggest, false); } //OAK-3156 @@ -295,9 +297,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = false; checkSuggestions(indexNodeType, queryNodeType, - indexPropName, indexPropValue, - true, false, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + true, false, + suggestQueryText, shouldSuggest, false); } //OAK-3156 @@ -310,9 +312,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = true; checkSuggestions(nodeType, - indexPropName, indexPropValue, - true, false, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + true, false, + suggestQueryText, shouldSuggest, false); } //OAK-3509 @@ -325,9 +327,9 @@ public class LuceneIndexSuggestionTest { final boolean shouldSuggest = true; checkSuggestions(nodeType, - indexPropName, indexPropValue, - true, false, - suggestQueryText, shouldSuggest, false); + indexPropName, indexPropValue, + true, false, + suggestQueryText, shouldSuggest, false); } //OAK-3407 @@ -339,9 +341,9 @@ public class LuceneIndexSuggestionTest { final String suggestQueryText = "sa"; checkSuggestions(nodeType, - indexPropName, indexPropValue, - true, true, - suggestQueryText, true, true); + indexPropName, indexPropValue, + true, true, + suggestQueryText, true, true); } //OAK-3149 @@ -353,9 +355,9 @@ public class LuceneIndexSuggestionTest { final String suggestQueryText = "sa"; checkSuggestions(nodeType, - indexPropName, indexPropValue, - true, true, - suggestQueryText, true, false); + indexPropName, indexPropValue, + true, true, + suggestQueryText, true, false); } //OAK-4067 @@ -367,8 +369,8 @@ public class LuceneIndexSuggestionTest { final String suggestQueryText = null; checkSuggestions(nodeType, - indexPropName, indexPropValue, - true, true, - suggestQueryText, false, false); + indexPropName, indexPropValue, + true, true, + suggestQueryText, false, false); } } Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexTest.java Tue Sep 25 12:24:15 2018 @@ -41,19 +41,19 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANL_FILTERS; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANL_NAME; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANL_TOKENIZER; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_NAMES; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_RULES; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PERSISTENCE_FILE; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PERSISTENCE_NAME; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PERSISTENCE_PATH; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.NT_TEST; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.createNodeWithType; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.newLuceneIndexDefinitionV2; import static org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition; import static org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition; import static org.apache.jackrabbit.oak.plugins.index.lucene.writer.IndexWriterUtils.getIndexWriterConfig; -import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INCLUDE_PROPERTY_NAMES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INDEX_RULES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PERSISTENCE_FILE; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PERSISTENCE_NAME; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PERSISTENCE_PATH; +import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; import java.io.File; import java.io.IOException; @@ -77,6 +77,9 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexDir; import org.apache.jackrabbit.oak.plugins.index.lucene.score.ScorerProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.score.ScorerProviderFactory; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.IndexFormatVersion; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; import org.apache.jackrabbit.oak.plugins.memory.PropertyValues; import org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider; @@ -85,8 +88,6 @@ import org.apache.jackrabbit.oak.query.a import org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider; import org.apache.jackrabbit.oak.query.ast.Operator; import org.apache.jackrabbit.oak.query.ast.SelectorImpl; -import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextParser; -import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm; import org.apache.jackrabbit.oak.query.index.FilterImpl; import org.apache.jackrabbit.oak.segment.SegmentNodeStoreBuilders; import org.apache.jackrabbit.oak.segment.memory.MemoryStore; @@ -102,6 +103,8 @@ import org.apache.jackrabbit.oak.spi.que import org.apache.jackrabbit.oak.spi.query.QueryIndex; import org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex; import org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan; +import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextParser; +import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStore; @@ -132,8 +135,8 @@ import com.google.common.collect.Sets; public class LuceneIndexTest { private static final EditorHook HOOK = new EditorHook( - new IndexUpdateProvider( - new LuceneIndexEditorProvider())); + new IndexUpdateProvider( + new LuceneIndexEditorProvider())); private NodeState root = INITIAL_CONTENT; @@ -147,7 +150,7 @@ public class LuceneIndexTest { public void testLuceneV1NonExistentProperty() throws Exception { NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); NodeBuilder defn = newLuceneIndexDefinition(index, "lucene", ImmutableSet.of("String")); - defn.setProperty(LuceneIndexConstants.COMPAT_MODE, IndexFormatVersion.V1.getVersion()); + defn.setProperty(FulltextIndexConstants.COMPAT_MODE, IndexFormatVersion.V1.getVersion()); NodeState before = builder.getNodeState(); builder.setProperty("foo", "value-with-dash"); @@ -195,7 +198,7 @@ public class LuceneIndexTest { FilterImpl filter = createFilter(NT_BASE); filter.restrictPath("/", Filter.PathRestriction.EXACT); filter.restrictProperty("foo", Operator.EQUAL, - PropertyValues.newString("bar")); + PropertyValues.newString("bar")); List<IndexPlan> plans = queryIndex.getPlans(filter, null, builder.getNodeState()); Cursor cursor = queryIndex.query(plans.get(0), indexed); assertTrue(cursor.hasNext()); @@ -224,7 +227,7 @@ public class LuceneIndexTest { AdvancedQueryIndex queryIndex = new LucenePropertyIndex(tracker); FilterImpl filter = createFilter(NT_BASE); filter.restrictProperty("foo", Operator.EQUAL, - PropertyValues.newString("bar")); + PropertyValues.newString("bar")); List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); @@ -258,7 +261,7 @@ public class LuceneIndexTest { FilterImpl filter = createFilter(NT_BASE); // filter.restrictPath("/", Filter.PathRestriction.EXACT); filter.restrictProperty("foo", Operator.EQUAL, - PropertyValues.newString("bar")); + PropertyValues.newString("bar")); List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); @@ -274,18 +277,18 @@ public class LuceneIndexTest { @Test public void testLucene3() throws Exception { NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); - NodeBuilder fooProp = rules.child("nt:base").child(LuceneIndexConstants.PROP_NODE).child("foo"); - fooProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - fooProp.setProperty(LuceneIndexConstants.PROP_INCLUDED_TYPE, PropertyType.TYPENAME_STRING); + NodeBuilder fooProp = rules.child("nt:base").child(FulltextIndexConstants.PROP_NODE).child("foo"); + fooProp.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + fooProp.setProperty(FulltextIndexConstants.PROP_INCLUDED_TYPE, PropertyType.TYPENAME_STRING); NodeState before = builder.getNodeState(); builder.setProperty("foo", "bar"); builder.child("a").setProperty("foo", "bar"); builder.child("a").child("b").setProperty("foo", "bar", Type.NAME); builder.child("a").child("b").child("c") - .setProperty("foo", "bar", Type.NAME); + .setProperty("foo", "bar", Type.NAME); NodeState after = builder.getNodeState(); @@ -297,7 +300,7 @@ public class LuceneIndexTest { FilterImpl filter = createFilter(NT_BASE); // filter.restrictPath("/", Filter.PathRestriction.EXACT); filter.restrictProperty("foo", Operator.EQUAL, - PropertyValues.newString("bar")); + PropertyValues.newString("bar")); List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); @@ -310,14 +313,14 @@ public class LuceneIndexTest { @Test public void testCursorStability() throws Exception { NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); - NodeBuilder fooProp = rules.child("nt:base").child(LuceneIndexConstants.PROP_NODE).child("foo"); - fooProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + NodeBuilder fooProp = rules.child("nt:base").child(FulltextIndexConstants.PROP_NODE).child("foo"); + fooProp.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); //1. Create 60 nodes NodeState before = builder.getNodeState(); - int noOfDocs = LucenePropertyIndex.LUCENE_QUERY_BATCH_SIZE + 10; + int noOfDocs = LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 10; for (int i = 0; i < noOfDocs; i++) { builder.child("a"+i).setProperty("foo", (long)i); } @@ -350,8 +353,8 @@ public class LuceneIndexTest { //Ensure that Lucene actually removes deleted docs NodeBuilder idx = builder.child(INDEX_DEFINITIONS_NAME).child("lucene"); - purgeDeletedDocs(idx, new IndexDefinition(root, idx.getNodeState(), "/foo")); - int numDeletes = getDeletedDocCount(idx, new IndexDefinition(root, idx.getNodeState(), "/foo")); + purgeDeletedDocs(idx, new LuceneIndexDefinition(root, idx.getNodeState(), "/foo")); + int numDeletes = getDeletedDocCount(idx, new LuceneIndexDefinition(root, idx.getNodeState(), "/foo")); Assert.assertEquals(0, numDeletes); //Update the IndexSearcher @@ -371,15 +374,15 @@ public class LuceneIndexTest { assertTrue(!uniquePaths.isEmpty()); } - private void purgeDeletedDocs(NodeBuilder idx, IndexDefinition definition) throws IOException { - Directory dir = new DefaultDirectoryFactory(null, null).newInstance(definition, idx, LuceneIndexConstants.INDEX_DATA_CHILD_NAME, false); + private void purgeDeletedDocs(NodeBuilder idx, LuceneIndexDefinition definition) throws IOException { + Directory dir = new DefaultDirectoryFactory(null, null).newInstance(definition, idx, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, false); IndexWriter writer = new IndexWriter(dir, getIndexWriterConfig(definition, true)); writer.forceMergeDeletes(); writer.close(); } - public int getDeletedDocCount(NodeBuilder idx, IndexDefinition definition) throws IOException { - Directory dir = new DefaultDirectoryFactory(null, null).newInstance(definition, idx, LuceneIndexConstants.INDEX_DATA_CHILD_NAME, false); + public int getDeletedDocCount(NodeBuilder idx, LuceneIndexDefinition definition) throws IOException { + Directory dir = new DefaultDirectoryFactory(null, null).newInstance(definition, idx, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, false); IndexReader reader = DirectoryReader.open(dir); int numDeletes = reader.numDeletedDocs(); reader.close(); @@ -391,13 +394,13 @@ public class LuceneIndexTest { root = TestUtil.registerTestNodeType(builder).getNodeState(); NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); - NodeBuilder propNode = rules.child(NT_TEST).child(LuceneIndexConstants.PROP_NODE); + NodeBuilder propNode = rules.child(NT_TEST).child(FulltextIndexConstants.PROP_NODE); NodeBuilder fooProp = propNode.child("foo"); - fooProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - fooProp.setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true); + fooProp.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + fooProp.setProperty(FulltextIndexConstants.PROP_NULL_CHECK_ENABLED, true); NodeState before = builder.getNodeState(); createNodeWithType(builder, "a", NT_TEST).setProperty("foo", "bar"); @@ -422,13 +425,13 @@ public class LuceneIndexTest { root = TestUtil.registerTestNodeType(builder).getNodeState(); NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); - NodeBuilder propNode = rules.child(NT_TEST).child(LuceneIndexConstants.PROP_NODE); + NodeBuilder propNode = rules.child(NT_TEST).child(FulltextIndexConstants.PROP_NODE); NodeBuilder fooProp = propNode.child("foo"); - fooProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - fooProp.setProperty(LuceneIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true); + fooProp.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + fooProp.setProperty(FulltextIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true); NodeState before = builder.getNodeState(); createNodeWithType(builder, "a", NT_TEST).setProperty("foo", "bar"); @@ -454,14 +457,14 @@ public class LuceneIndexTest { root = TestUtil.registerTestNodeType(builder).getNodeState(); NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); - NodeBuilder propNode = rules.child(NT_TEST).child(LuceneIndexConstants.PROP_NODE); + NodeBuilder propNode = rules.child(NT_TEST).child(FulltextIndexConstants.PROP_NODE); propNode.child("bar") - .setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/bar") - .setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true) - .setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true); + .setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/bar") + .setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true) + .setProperty(FulltextIndexConstants.PROP_NULL_CHECK_ENABLED, true); NodeState before = builder.getNodeState(); @@ -496,8 +499,8 @@ public class LuceneIndexTest { @Test public void testPathRestrictions() throws Exception { NodeBuilder idx = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); - idx.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true); + "lucene", ImmutableSet.of("foo"), null); + idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); NodeState before = builder.getNodeState(); builder.setProperty("foo", "bar"); @@ -534,10 +537,10 @@ public class LuceneIndexTest { @Test public void nodeNameIndex() throws Exception{ NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), - "lucene", ImmutableSet.of("foo"), null); + "lucene", ImmutableSet.of("foo"), null); NodeBuilder rules = index.child(INDEX_RULES); NodeBuilder ruleNode = rules.child(NT_FILE); - ruleNode.setProperty(LuceneIndexConstants.INDEX_NODE_NAME, true); + ruleNode.setProperty(FulltextIndexConstants.INDEX_NODE_NAME, true); NodeState before = builder.getNodeState(); createNodeWithType(builder, "foo", NT_FILE); @@ -572,7 +575,7 @@ public class LuceneIndexTest { @Test public void analyzerWithStopWords() throws Exception{ NodeBuilder nb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", - of(TYPENAME_STRING)); + of(TYPENAME_STRING)); TestUtil.useV2(nb); NodeState before = builder.getNodeState(); builder.setProperty("foo", "fox jumping"); @@ -618,9 +621,9 @@ public class LuceneIndexTest { @Test public void customScoreQuery() throws Exception{ NodeBuilder nb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", - of(TYPENAME_STRING)); + of(TYPENAME_STRING)); TestUtil.useV2(nb); - nb.setProperty(LuceneIndexConstants.PROP_SCORER_PROVIDER, "testScorer"); + nb.setProperty(FulltextIndexConstants.PROP_SCORER_PROVIDER, "testScorer"); NodeState before = builder.getNodeState(); builder.child("a").setProperty("jcr:createdBy", "bar bar"); @@ -684,26 +687,26 @@ public class LuceneIndexTest { public void testTokens() { Analyzer analyzer = LuceneIndexConstants.ANALYZER; assertEquals(ImmutableList.of("parent", "child"), - LuceneIndex.tokenize("/parent/child", analyzer)); + LuceneIndex.tokenize("/parent/child", analyzer)); assertEquals(ImmutableList.of("p1234", "p5678"), - LuceneIndex.tokenize("/p1234/p5678", analyzer)); + LuceneIndex.tokenize("/p1234/p5678", analyzer)); assertEquals(ImmutableList.of("first", "second"), - LuceneIndex.tokenize("first_second", analyzer)); + LuceneIndex.tokenize("first_second", analyzer)); assertEquals(ImmutableList.of("first1", "second2"), - LuceneIndex.tokenize("first1_second2", analyzer)); + LuceneIndex.tokenize("first1_second2", analyzer)); assertEquals(ImmutableList.of("first", "second"), - LuceneIndex.tokenize("first. second", analyzer)); + LuceneIndex.tokenize("first. second", analyzer)); assertEquals(ImmutableList.of("first", "second"), - LuceneIndex.tokenize("first.second", analyzer)); + LuceneIndex.tokenize("first.second", analyzer)); assertEquals(ImmutableList.of("hello", "world"), - LuceneIndex.tokenize("hello-world", analyzer)); + LuceneIndex.tokenize("hello-world", analyzer)); assertEquals(ImmutableList.of("hello", "wor*"), - LuceneIndex.tokenize("hello-wor*", analyzer)); + LuceneIndex.tokenize("hello-wor*", analyzer)); assertEquals(ImmutableList.of("*llo", "world"), - LuceneIndex.tokenize("*llo-world", analyzer)); + LuceneIndex.tokenize("*llo-world", analyzer)); assertEquals(ImmutableList.of("*llo", "wor*"), - LuceneIndex.tokenize("*llo-wor*", analyzer)); + LuceneIndex.tokenize("*llo-wor*", analyzer)); } @Test @@ -773,7 +776,7 @@ public class LuceneIndexTest { public void luceneWithCopyOnReadDirAndReindex() throws Exception{ NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); NodeBuilder defnState = - newLucenePropertyIndexDefinition(index, "lucene", ImmutableSet.of("foo", "foo2", "foo3"), null); + newLucenePropertyIndexDefinition(index, "lucene", ImmutableSet.of("foo", "foo2", "foo3"), null); IndexDefinition definition = new IndexDefinition(root, defnState.getNodeState(), "/foo"); //1. Create index in two increments @@ -832,9 +835,9 @@ public class LuceneIndexTest { public void multiValuesForOrderedIndexShouldNotThrow() { NodeBuilder index = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", null); NodeBuilder singleProp = TestUtil.child(index, "indexRules/nt:base/properties/single"); - singleProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - singleProp.setProperty(LuceneIndexConstants.PROP_ORDERED, true); - singleProp.setProperty(LuceneIndexConstants.PROP_INCLUDED_TYPE, PropertyType.TYPENAME_STRING); + singleProp.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + singleProp.setProperty(FulltextIndexConstants.PROP_ORDERED, true); + singleProp.setProperty(FulltextIndexConstants.PROP_INCLUDED_TYPE, PropertyType.TYPENAME_STRING); NodeState before = builder.getNodeState(); builder.setProperty("single", asList("baz", "bar"), Type.STRINGS); @@ -852,16 +855,16 @@ public class LuceneIndexTest { tracker = new IndexTracker(); //Create 2 indexes. /oak:index/lucene and /test/oak:index/lucene - //The way LuceneIndexLookup works is. It collect child first and then + //The way LuceneIndexLookupUtil works is. It collect child first and then //parent NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); NodeBuilder nb = newLuceneIndexDefinitionV2(index, "lucene", of(TYPENAME_STRING)); - nb.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, false); + nb.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); nb.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo"), STRINGS)); index = builder.child("test").child(INDEX_DEFINITIONS_NAME); NodeBuilder nb2 = newLuceneIndexDefinitionV2(index, "lucene", of(TYPENAME_STRING)); - nb2.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, false); + nb2.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); nb2.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo"), STRINGS)); NodeState before = builder.getNodeState(); @@ -936,7 +939,7 @@ public class LuceneIndexTest { FilterImpl filter = createFilter(NT_BASE); filter.restrictPath("/", Filter.PathRestriction.EXACT); filter.restrictProperty(key, Operator.EQUAL, - PropertyValues.newString(value)); + PropertyValues.newString(value)); List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed); Cursor cursor = queryIndex.query(plans.get(0), indexed); assertTrue(cursor.hasNext()); @@ -958,7 +961,7 @@ public class LuceneIndexTest { assertTrue("Expected path " + p + " not found", paths.contains(p)); } assertEquals("Result set size is different \nExpected: " + - expected + "\nActual: " + paths, expected.size(), paths.size()); + expected + "\nActual: " + paths, expected.size(), paths.size()); return paths; } Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndexTest.java Tue Sep 25 12:24:15 2018 @@ -52,7 +52,6 @@ import com.google.common.io.CountingInpu import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.JcrConstants; -import org.apache.jackrabbit.oak.InitialContent; import org.apache.jackrabbit.oak.Oak; import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.api.CommitFailedException; @@ -76,6 +75,10 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.util.fv.SimSearchUtils; import org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider; import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider; +import org.apache.jackrabbit.oak.plugins.index.search.ExtractedTextCache; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.IndexFormatVersion; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; @@ -121,24 +124,24 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.QUERY_PATHS; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; -import static org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.INDEX_DEFINITION_NODE; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ANALYZERS; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INCLUDE_PROPERTY_NAMES; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_ORIGINAL_TERM; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.ORDERED_PROP_NAMES; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROPDEF_PROP_NODE_NAME; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_ANALYZED; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_NAME; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_NODE; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_NODE_SCOPE_INDEX; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_PROPERTY_INDEX; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PROP_TYPE; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.TIKA; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorTest.createCal; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.child; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.newNodeAggregator; import static org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.useV2; +import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorTest.createCal; import static org.apache.jackrabbit.oak.plugins.index.property.OrderedIndex.OrderDirection; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.INCLUDE_PROPERTY_NAMES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.ORDERED_PROP_NAMES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_ANALYZED; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_NAME; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_NODE; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_NODE_SCOPE_INDEX; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_PROPERTY_INDEX; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_TYPE; +import static org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.INDEX_DEFINITION_NODE; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; import static org.apache.jackrabbit.oak.spi.filter.PathFilter.PROP_EXCLUDED_PATHS; import static org.apache.jackrabbit.oak.spi.filter.PathFilter.PROP_INCLUDED_PATHS; @@ -210,7 +213,7 @@ public class LucenePropertyIndexTest ext try { return new IndexCopier(executorService, temporaryFolder.getRoot()) { @Override - public Directory wrapForRead(String indexPath, IndexDefinition definition, + public Directory wrapForRead(String indexPath, LuceneIndexDefinition definition, Directory remote, String dirName) throws IOException { Directory ret = super.wrapForRead(indexPath, definition, remote, dirName); corDir = getFSDirPath(ret); @@ -218,7 +221,7 @@ public class LucenePropertyIndexTest ext } @Override - public Directory wrapForWrite(IndexDefinition definition, + public Directory wrapForWrite(LuceneIndexDefinition definition, Directory remote, boolean reindexMode, String dirName) throws IOException { Directory ret = super.wrapForWrite(definition, remote, reindexMode, dirName); cowDir = getFSDirPath(ret); @@ -493,7 +496,7 @@ public class LucenePropertyIndexTest ext Tree indexWithType = createIndex("test2", of("propb")); indexWithType.setProperty(PropertyStates.createProperty(DECLARING_NODE_TYPES, of("nt:file"), NAMES)); - indexWithType.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true); + indexWithType.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, true); TestUtil.useV2(indexWithType); Tree test = root.getTree("/").addChild("test"); @@ -518,7 +521,7 @@ public class LucenePropertyIndexTest ext @Test public void nodeName() throws Exception{ Tree idx = createIndex("test1", of("propa", "propb")); - Tree rules = idx.addChild(LuceneIndexConstants.INDEX_RULES); + Tree rules = idx.addChild(FulltextIndexConstants.INDEX_RULES); rules.setOrderableChildren(true); Tree rule = rules.addChild("nt:base"); rule.setProperty(LuceneIndexConstants.INDEX_NODE_NAME, true); @@ -548,7 +551,7 @@ public class LucenePropertyIndexTest ext //make index Tree idx = createIndex("test1", Collections.EMPTY_SET); useV2(idx); - Tree rules = idx.addChild(LuceneIndexConstants.INDEX_RULES); + Tree rules = idx.addChild(FulltextIndexConstants.INDEX_RULES); rules.setOrderableChildren(true); Tree rule = rules.addChild("nt:base"); Tree propDef = rule.addChild(PROP_NODE).addChild("nodeName"); @@ -697,8 +700,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, TestUtil.NT_TEST); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "propa"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(PROP_NAME, "propa"); + prop.setProperty(PROP_PROPERTY_INDEX, true); prop.setProperty(LuceneIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true); root.commit(); @@ -720,8 +723,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, TestUtil.NT_TEST); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "propa"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(PROP_NAME, "propa"); + prop.setProperty(PROP_PROPERTY_INDEX, true); prop.setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true); root.commit(); @@ -827,7 +830,7 @@ public class LucenePropertyIndexTest ext public void rangeQueriesWithLong() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); Tree propIdx = idx.addChild(PROP_NODE).addChild("propa"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1193,7 +1196,7 @@ public class LucenePropertyIndexTest ext public void rangeQueriesWithDouble() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); Tree propIdx = idx.addChild(PROP_NODE).addChild("propa"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1243,7 +1246,7 @@ public class LucenePropertyIndexTest ext public void rangeQueriesWithDate() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); Tree propIdx = idx.addChild(PROP_NODE).addChild("propa"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1285,7 +1288,7 @@ public class LucenePropertyIndexTest ext public void nativeQueries() throws Exception { Tree idx = createIndex("test1", of("propa", "propb")); idx.addChild(PROP_NODE).addChild("propa"); - idx.setProperty(LuceneIndexConstants.FUNC_NAME, "foo"); + idx.setProperty(FulltextIndexConstants.FUNC_NAME, "foo"); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1316,7 +1319,7 @@ public class LucenePropertyIndexTest ext public void indexDefinitionBelowRoot() throws Exception { Tree parent = root.getTree("/").addChild("test"); Tree idx = createIndex(parent, "test1", of("propa", "propb")); - idx.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true); + idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); idx.addChild(PROP_NODE).addChild("propa"); root.commit(); @@ -1331,7 +1334,7 @@ public class LucenePropertyIndexTest ext public void indexDefinitionBelowRoot2() throws Exception { Tree parent = root.getTree("/").addChild("test"); Tree idx = createIndex(parent, "test1", of("propa", "propb")); - idx.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true); + idx.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); idx.addChild(PROP_NODE).addChild("propa"); root.commit(); @@ -1410,7 +1413,7 @@ public class LucenePropertyIndexTest ext public void sortQueriesWithLong() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); assertSortedLong(); @@ -1422,7 +1425,7 @@ public class LucenePropertyIndexTest ext idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); assertSortedLong(); @@ -1433,7 +1436,7 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", Collections.<String>emptySet()); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); assertThat(explain("select [jcr:path] from [nt:base] order by [jcr:score], [foo]"), containsString("lucene:test1")); @@ -1450,7 +1453,7 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", Collections.<String>emptySet()); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo/bar"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo").addChild("bar"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); assertThat(explain("select [jcr:path] from [nt:base] order by [foo/bar]"), containsString("lucene:test1")); @@ -1493,7 +1496,7 @@ public class LucenePropertyIndexTest ext public void sortQueriesWithDouble() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); root.commit(); assertSortedDouble(); @@ -1505,7 +1508,7 @@ public class LucenePropertyIndexTest ext idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DOUBLE); root.commit(); assertSortedDouble(); @@ -1602,7 +1605,7 @@ public class LucenePropertyIndexTest ext public void sortQueriesWithDate() throws Exception { Tree idx = createIndex("test1", of("foo", "bar")); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); root.commit(); assertSortedDate(); @@ -1614,7 +1617,7 @@ public class LucenePropertyIndexTest ext idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); root.commit(); assertSortedDate(); @@ -1645,7 +1648,7 @@ public class LucenePropertyIndexTest ext idx.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("bar"), STRINGS)); idx.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("foo"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1679,7 +1682,7 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("foo", "bar", "baz")); idx.setProperty(createProperty(ORDERED_PROP_NAMES, ImmutableSet.of("foo", "baz"), STRINGS)); Tree propIdx = idx.addChild(PROP_NODE).addChild("baz"); - propIdx.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); + propIdx.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -1705,22 +1708,22 @@ public class LucenePropertyIndexTest ext public void indexTimeFieldBoost() throws Exception { // Index Definition Tree idx = createIndex("test1", of("propa", "propb", "propc")); - idx.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true); + idx.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, true); Tree propNode = idx.addChild(PROP_NODE); // property definition for index test1 Tree propA = propNode.addChild("propa"); - propA.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); - propA.setProperty(LuceneIndexConstants.FIELD_BOOST, 2.0); + propA.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); + propA.setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); Tree propB = propNode.addChild("propb"); - propB.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); - propB.setProperty(LuceneIndexConstants.FIELD_BOOST, 1.0); + propB.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); + propB.setProperty(FulltextIndexConstants.FIELD_BOOST, 1.0); Tree propC = propNode.addChild("propc"); - propC.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); - propC.setProperty(LuceneIndexConstants.FIELD_BOOST, 4.0); + propC.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); + propC.setProperty(FulltextIndexConstants.FIELD_BOOST, 4.0); root.commit(); // create test data @@ -1745,18 +1748,18 @@ public class LucenePropertyIndexTest ext Tree props = TestUtil.newRulePropTree(idx, TestUtil.NT_TEST); Tree title = props.addChild("title"); - title.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/jcr:title"); - title.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true); - title.setProperty(LuceneIndexConstants.FIELD_BOOST, 4.0); + title.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/jcr:title"); + title.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true); + title.setProperty(FulltextIndexConstants.FIELD_BOOST, 4.0); Tree desc = props.addChild("desc"); - desc.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/jcr:description"); - desc.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true); - desc.setProperty(LuceneIndexConstants.FIELD_BOOST, 2.0); + desc.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/jcr:description"); + desc.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true); + desc.setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); Tree text = props.addChild("text"); - text.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/text"); - text.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true); + text.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/text"); + text.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true); root.commit(); @@ -1815,7 +1818,7 @@ public class LucenePropertyIndexTest ext public void sortFulltextQueriesWithJcrScore() throws Exception { // Index Definition Tree idx = createIndex("test1", of("propa")); - idx.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true); + idx.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, true); useV2(idx); // create test data @@ -1839,7 +1842,7 @@ public class LucenePropertyIndexTest ext private void fulltextBooleanComplexOrQueries(boolean ver2) throws Exception { // Index Definition Tree idx = createIndex("test1", of("propa", "propb")); - idx.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true); + idx.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, true); if (ver2) { useV2(idx); } @@ -2158,14 +2161,14 @@ public class LucenePropertyIndexTest ext // Index Definition Tree idx = createIndex("test1", of("propa", "propb")); TestUtil.useV2(idx); - idx.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, true); + idx.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, true); Tree propNode = idx.addChild(PROP_NODE); // property definition for index test1 Tree propA = propNode.addChild("propa"); - propA.setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); - propA.setProperty(LuceneIndexConstants.FIELD_BOOST, 2.0); + propA.setProperty(FulltextIndexConstants.PROP_TYPE, PropertyType.TYPENAME_STRING); + propA.setProperty(FulltextIndexConstants.FIELD_BOOST, 2.0); root.commit(); @@ -2276,13 +2279,13 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, TestUtil.NT_TEST); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "original/jcr:content/type"); - prop1.setProperty(LuceneIndexConstants.PROP_EXCLUDE_FROM_AGGREGATE, true); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "original/jcr:content/type"); + prop1.setProperty(FulltextIndexConstants.PROP_EXCLUDE_FROM_AGGREGATE, true); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); newNodeAggregator(idx) .newRuleWithName(NT_FILE, newArrayList(JCR_CONTENT, JCR_CONTENT + "/*")) @@ -2314,12 +2317,12 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, TestUtil.NT_TEST); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "original/jcr:content/type"); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "original/jcr:content/type"); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); newNodeAggregator(idx) .newRuleWithName(NT_FILE, newArrayList(JCR_CONTENT, JCR_CONTENT + "/*")) @@ -2350,8 +2353,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "mix:title"); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2370,8 +2373,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "mix:mimeType"); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:mimeType"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:mimeType"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2398,9 +2401,9 @@ public class LucenePropertyIndexTest ext idx.setProperty(REINDEX_PROPERTY_NAME, true); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop = props.addChild(TestUtil.unique("jcr:mimeType")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:mimeType"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - prop.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:mimeType"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2438,9 +2441,9 @@ public class LucenePropertyIndexTest ext idx.setProperty(REINDEX_PROPERTY_NAME, true); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop = props.addChild(TestUtil.unique("text")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, "text"); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - prop.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); + prop.setProperty(FulltextIndexConstants.PROP_NAME, "text"); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2462,12 +2465,12 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "mix:title"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); Tree prop2 = props.addChild(TestUtil.unique("prop")); - prop2.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/type"); - prop2.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop2.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/type"); + prop2.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2492,8 +2495,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "mix:title"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); //force CoR @@ -2517,8 +2520,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:title"); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:title"); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); root.commit(); //Make some changes such incremental indexing happens @@ -2551,8 +2554,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "tag"); - prop1.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "tag"); + prop1.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2583,8 +2586,8 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "jcr:content/metadata/comment"); - prop1.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "jcr:content/metadata/comment"); + prop1.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); root.commit(); Tree test = root.getTree("/").addChild("test"); @@ -2664,9 +2667,9 @@ public class LucenePropertyIndexTest ext Tree idx = createIndex("test1", of("propa", "propb")); Tree props = TestUtil.newRulePropTree(idx, "nt:base"); Tree prop1 = props.addChild(TestUtil.unique("prop")); - prop1.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - prop1.setProperty(LuceneIndexConstants.PROP_NAME, "tag"); - prop1.setProperty(LuceneIndexConstants.PROP_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + prop1.setProperty(FulltextIndexConstants.PROP_NAME, "tag"); + prop1.setProperty(FulltextIndexConstants.PROP_INDEX, true); prop1.setProperty(LuceneIndexConstants.PROP_USE_IN_SUGGEST, true); root.commit(); @@ -2842,12 +2845,12 @@ public class LucenePropertyIndexTest ext assertThat(explain(query), not(containsString("lucene:test1(/oak:index/test1)"))); //Instead of reindex just refresh the index definition so that new index definition gets picked up - root.getTree("/oak:index/test1").setProperty(LuceneIndexConstants.PROP_REFRESH_DEFN, true); + root.getTree("/oak:index/test1").setProperty(FulltextIndexConstants.PROP_REFRESH_DEFN, true); root.commit(); //Plan would reflect new defintion assertThat(explain(query), containsString("lucene:test1(/oak:index/test1)")); - assertFalse(root.getTree("/oak:index/test1").hasProperty(LuceneIndexConstants.PROP_REFRESH_DEFN)); + assertFalse(root.getTree("/oak:index/test1").hasProperty(FulltextIndexConstants.PROP_REFRESH_DEFN)); //However as reindex was not done query would result in empty set assertPlanAndQuery(query, "lucene:test1(/oak:index/test1)", Collections.<String>emptyList()); @@ -3082,11 +3085,11 @@ public class LucenePropertyIndexTest ext private Tree addPropertyDefn(Tree indexDefn, String propName, double boost){ Tree props = TestUtil.newRulePropTree(indexDefn, "oak:Unstructured"); Tree prop = props.addChild(TestUtil.unique("prop")); - prop.setProperty(LuceneIndexConstants.PROP_NAME, propName); - prop.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true); - prop.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); - prop.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true); - prop.setProperty(LuceneIndexConstants.FIELD_BOOST, boost); + prop.setProperty(FulltextIndexConstants.PROP_NAME, propName); + prop.setProperty(FulltextIndexConstants.PROP_PROPERTY_INDEX, true); + prop.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); + prop.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true); + prop.setProperty(FulltextIndexConstants.FIELD_BOOST, boost); return prop; } @@ -3132,8 +3135,8 @@ public class LucenePropertyIndexTest ext INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); def.setProperty(REINDEX_PROPERTY_NAME, true); - def.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, false); - def.setProperty(PropertyStates.createProperty(LuceneIndexConstants.INCLUDE_PROPERTY_NAMES, propNames, Type.STRINGS)); + def.setProperty(FulltextIndexConstants.FULL_TEXT_ENABLED, false); + def.setProperty(PropertyStates.createProperty(FulltextIndexConstants.INCLUDE_PROPERTY_NAMES, propNames, Type.STRINGS)); def.setProperty(LuceneIndexConstants.SAVE_DIR_LISTING, true); return index.getChild(INDEX_DEFINITIONS_NAME).getChild(name); } @@ -3143,19 +3146,19 @@ public class LucenePropertyIndexTest ext def.setProperty(JcrConstants.JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, Type.NAME); def.setProperty(TYPE_PROPERTY_NAME, LuceneIndexConstants.TYPE_LUCENE); def.setProperty(REINDEX_PROPERTY_NAME, true); - def.setProperty(LuceneIndexConstants.EVALUATE_PATH_RESTRICTION, true); - def.setProperty(LuceneIndexConstants.COMPAT_MODE, IndexFormatVersion.V2.getVersion()); + def.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true); + def.setProperty(FulltextIndexConstants.COMPAT_MODE, IndexFormatVersion.V2.getVersion()); - Tree props = def.addChild(LuceneIndexConstants.INDEX_RULES) + Tree props = def.addChild(FulltextIndexConstants.INDEX_RULES) .addChild("nt:base") - .addChild(LuceneIndexConstants.PROP_NODE) + .addChild(FulltextIndexConstants.PROP_NODE) .addChild("allProps"); - props.setProperty(LuceneIndexConstants.PROP_ANALYZED, true); - props.setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true); - props.setProperty(LuceneIndexConstants.PROP_USE_IN_EXCERPT, true); - props.setProperty(LuceneIndexConstants.PROP_NAME, LuceneIndexConstants.REGEX_ALL_PROPS); - props.setProperty(LuceneIndexConstants.PROP_IS_REGEX, true); + props.setProperty(FulltextIndexConstants.PROP_ANALYZED, true); + props.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true); + props.setProperty(FulltextIndexConstants.PROP_USE_IN_EXCERPT, true); + props.setProperty(FulltextIndexConstants.PROP_NAME, FulltextIndexConstants.REGEX_ALL_PROPS); + props.setProperty(FulltextIndexConstants.PROP_IS_REGEX, true); return def; }