Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DelayedFacetReadTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DelayedFacetReadTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DelayedFacetReadTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/DelayedFacetReadTest.java Mon Jun 29 06:49:51 2020 @@ -32,14 +32,13 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider; -import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexNodeManager; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.LucenePropertyIndex; import org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil; import org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.OptionalEditorProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; 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.FulltextIndexConstants; @@ -56,7 +55,6 @@ import org.apache.jackrabbit.oak.stats.C import org.apache.jackrabbit.oak.stats.StatisticsProvider; import org.jetbrains.annotations.Nullable; import org.junit.After; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -264,7 +262,7 @@ public class DelayedFacetReadTest extend } private Tree createIndex(Tree index, String name) throws RepositoryException { - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); idxBuilder.noAsync() .indexRule("nt:base") .property("cons").propertyIndex()
Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ExternalIndexObserverTest.java Mon Jun 29 06:49:51 2020 @@ -25,7 +25,7 @@ import com.google.common.collect.Multima import com.google.common.util.concurrent.MoreExecutors; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.spi.commit.CommitContext; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.Observer; @@ -194,7 +194,7 @@ public class ExternalIndexObserverTest { } private static LuceneIndexDefinition createNRTIndex(String ruleName) { - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule(ruleName).property("foo").propertyIndex(); idx.async("async", "sync"); return new LuceneIndexDefinition(INITIAL_CONTENT, idx.build(), "/oak:index/foo"); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/FacetCacheTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/FacetCacheTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/FacetCacheTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/FacetCacheTest.java Mon Jun 29 06:49:51 2020 @@ -41,7 +41,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.OptionalEditorProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; 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.FulltextIndexConstants; @@ -58,8 +58,6 @@ import org.apache.jackrabbit.oak.stats.C import org.apache.jackrabbit.oak.stats.StatisticsProvider; import org.jetbrains.annotations.Nullable; import org.junit.After; -import org.junit.Assert; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -300,7 +298,7 @@ public class FacetCacheTest extends Abst } private Tree createIndex(Tree index, String name) throws RepositoryException { - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); idxBuilder.noAsync() .indexRule("nt:base") .property("cons").propertyIndex() Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexClusterIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexClusterIT.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexClusterIT.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexClusterIT.java Mon Jun 29 06:49:51 2020 @@ -53,7 +53,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.query.QueryEngineSettings; import org.apache.jackrabbit.oak.spi.commit.Observer; import org.apache.jackrabbit.oak.spi.mount.MountInfoProvider; @@ -149,7 +149,7 @@ public class HybridIndexClusterIT extend nswb1.register(JournalPropertyService.class, new LuceneJournalPropertyService(1000), null); nswb2.register(JournalPropertyService.class, new LuceneJournalPropertyService(1000), null); - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule("nt:base").property("foo").propertyIndex(); idx.async("async", "sync"); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/HybridIndexTest.java Mon Jun 29 06:49:51 2020 @@ -67,12 +67,12 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder.IndexRule; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; 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.FulltextIndexConstants; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.memory.ArrayBasedBlob; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider; @@ -315,7 +315,7 @@ public class HybridIndexTest extends Abs @Test public void newNodeTypesFoundLater2() throws Exception{ String idxName = "hybridtest"; - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule("oak:TestNode") .property(JcrConstants.JCR_PRIMARYTYPE).propertyIndex(); idx.indexRule("nt:base") @@ -505,8 +505,8 @@ public class HybridIndexTest extends Abs } private static Tree createIndex(Tree index, String name, Set<String> propNames){ - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); - IndexRule rule = idx.indexRule("nt:base"); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); + IndexDefinitionBuilder.IndexRule rule = idx.indexRule("nt:base"); for (String propName : propNames){ rule.property(propName).propertyIndex(); } @@ -516,7 +516,7 @@ public class HybridIndexTest extends Abs } private static Tree createFulltextIndex(Tree index, String name){ - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.evaluatePathRestrictions(); idx.indexRule("nt:base") .property(FulltextIndexConstants.REGEX_ALL_PROPS, true) Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LocalIndexWriterFactoryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LocalIndexWriterFactoryTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LocalIndexWriterFactoryTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/LocalIndexWriterFactoryTest.java Mon Jun 29 06:49:51 2020 @@ -29,7 +29,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker; import org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; import org.apache.jackrabbit.oak.spi.commit.CommitContext; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; @@ -197,7 +197,7 @@ public class LocalIndexWriterFactoryTest } private void createIndexDefinition(String idxName, FulltextIndexConstants.IndexingMode indexingMode) { - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); TestUtil.enableIndexingMode(idx.getBuilderTree(), indexingMode); idx.indexRule("nt:base").property("foo").propertyIndex(); builder.child("oak:index").setChildNode(idxName, idx.build()); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/MultithreadedOldLuceneFacetProviderReadFailureTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/MultithreadedOldLuceneFacetProviderReadFailureTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/MultithreadedOldLuceneFacetProviderReadFailureTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/MultithreadedOldLuceneFacetProviderReadFailureTest.java Mon Jun 29 06:49:51 2020 @@ -39,7 +39,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.TestUtil.OptionalEditorProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; 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.FulltextIndexConstants; @@ -272,7 +272,7 @@ public class MultithreadedOldLuceneFacet } private Tree createIndex(Tree index, String name) throws RepositoryException { - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); idxBuilder.noAsync() .indexRule("nt:base") .property("cons").propertyIndex() Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ReaderRefCountIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ReaderRefCountIT.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ReaderRefCountIT.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/hybrid/ReaderRefCountIT.java Mon Jun 29 06:49:51 2020 @@ -36,7 +36,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexNode; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorContext; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.stats.Clock; @@ -72,7 +72,7 @@ public class ReaderRefCountIT { @Test public void syncIndex() throws Exception{ - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule("nt:base").property("foo").propertyIndex(); idx.async("async", "sync"); @@ -82,7 +82,7 @@ public class ReaderRefCountIT { @Test public void nrtIndex() throws Exception{ - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule("nt:base").property("foo").propertyIndex(); idx.async("async", "nrt"); @@ -98,7 +98,7 @@ public class ReaderRefCountIT { */ @Test public void indexTrackerUpdatesAndNRT() throws Exception{ - IndexDefinitionBuilder idx = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idx = new LuceneIndexDefinitionBuilder(); idx.indexRule("nt:base").property("foo").propertyIndex(); idx.async("async", "nrt"); @@ -107,7 +107,7 @@ public class ReaderRefCountIT { runMultiReaderScenario(idx, nrtFactory, true); } - private void runMultiReaderScenario(IndexDefinitionBuilder defnb, + private void runMultiReaderScenario(LuceneIndexDefinitionBuilder defnb, NRTIndexFactory nrtFactory, boolean updateIndex) throws Exception{ NodeBuilder builder = root.builder(); builder.child("oak:index").setChildNode("fooIndex", defnb.build()); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexLookupTest.java Mon Jun 29 06:49:51 2020 @@ -23,7 +23,7 @@ import java.util.List; import com.google.common.collect.ImmutableList; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; import org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider; @@ -49,7 +49,7 @@ import static org.junit.Assert.assertTha public class HybridPropertyIndexLookupTest { private NodeState root = INITIAL_CONTENT; private NodeBuilder builder = EMPTY_NODE.builder(); - private IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + private LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); private String indexPath = "/oak:index/foo"; private PropertyIndexUpdateCallback callback = new PropertyIndexUpdateCallback(indexPath, builder, root); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/HybridPropertyIndexStorageTest.java Mon Jun 29 06:49:51 2020 @@ -23,7 +23,7 @@ import java.util.List; import com.google.common.collect.ImmutableList; import org.apache.jackrabbit.oak.api.PropertyValue; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyUpdateCallback; @@ -53,7 +53,7 @@ import static org.junit.Assert.assertTha public class HybridPropertyIndexStorageTest { private NodeState root = INITIAL_CONTENT; private NodeBuilder builder = EMPTY_NODE.builder(); - private IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + private LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); private String indexPath = "/oak:index/foo"; @Test Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/LuceneIndexPropertyQueryTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/LuceneIndexPropertyQueryTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/LuceneIndexPropertyQueryTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/LuceneIndexPropertyQueryTest.java Mon Jun 29 06:49:51 2020 @@ -23,7 +23,7 @@ import com.google.common.collect.Iterabl import org.apache.jackrabbit.oak.plugins.index.IndexUpdateProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EditorHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -41,7 +41,7 @@ public class LuceneIndexPropertyQueryTes private IndexTracker tracker = new IndexTracker(); private String indexPath = "/oak:index/foo"; - private IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(child(builder, indexPath)); + private LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(child(builder, indexPath)); private LuceneIndexPropertyQuery query = new LuceneIndexPropertyQuery(tracker, indexPath); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/PropertyIndexCleanerTest.java Mon Jun 29 06:49:51 2020 @@ -32,7 +32,7 @@ import org.apache.jackrabbit.oak.api.Com import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfo; import org.apache.jackrabbit.oak.plugins.index.AsyncIndexInfoService; import org.apache.jackrabbit.oak.plugins.index.lucene.property.PropertyIndexCleaner.CleanupStats; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyUpdateCallback; @@ -79,7 +79,7 @@ public class PropertyIndexCleanerTest { @Test public void syncIndexPaths() throws Exception{ - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); defnb.indexRule("nt:base").property("foo").propertyIndex().sync(); String indexPath = "/oak:index/foo"; addIndex(indexPath, defnb); @@ -101,7 +101,7 @@ public class PropertyIndexCleanerTest { @Test public void simplePropertyIndexCleaning() throws Exception{ - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); defnb.indexRule("nt:base").property("foo").propertyIndex().sync(); String indexPath = "/oak:index/foo"; addIndex(indexPath, defnb); @@ -146,7 +146,7 @@ public class PropertyIndexCleanerTest { @Test public void uniqueIndexCleaning() throws Exception{ - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); defnb.indexRule("nt:base").property("foo").propertyIndex().unique(); String indexPath = "/oak:index/foo"; addIndex(indexPath, defnb); @@ -214,7 +214,7 @@ public class PropertyIndexCleanerTest { @Test public void noRunPerformedIfNoChangeInAsync() throws Exception{ - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); defnb.indexRule("nt:base").property("foo").propertyIndex().sync(); String indexPath = "/oak:index/foo"; addIndex(indexPath, defnb); @@ -255,7 +255,7 @@ public class PropertyIndexCleanerTest { @Test public void recursiveDelete() throws Exception{ - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); defnb.indexRule("nt:base").property("foo").propertyIndex().sync(); String indexPath = "/oak:index/foo"; addIndex(indexPath, defnb); @@ -301,7 +301,7 @@ public class PropertyIndexCleanerTest { } } - private void addIndex(String indexPath, IndexDefinitionBuilder defnb) throws CommitFailedException { + private void addIndex(String indexPath, LuceneIndexDefinitionBuilder defnb) throws CommitFailedException { NodeBuilder nb = nodeStore.getRoot().builder(); child(nb, getParentPath(indexPath)).setChildNode(getName(indexPath), defnb.build()); merge(nb); Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/SynchronousPropertyIndexTest.java Mon Jun 29 06:49:51 2020 @@ -54,7 +54,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndexFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.DefaultIndexReaderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.reader.LuceneIndexReaderFactory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider; import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; @@ -109,7 +109,7 @@ public class SynchronousPropertyIndexTes private Whiteboard wb; - private IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + private LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); private String indexPath = "/oak:index/foo"; private DelayingIndexEditor delayingEditorProvider = new DelayingIndexEditor(); private TestUtil.OptionalEditorProvider optionalEditorProvider = new TestUtil.OptionalEditorProvider(); @@ -495,7 +495,7 @@ public class SynchronousPropertyIndexTes return executeQuery(explain, "JCR-SQL2").get(0); } - private void addIndex(String indexPath, IndexDefinitionBuilder defnb){ + private void addIndex(String indexPath, LuceneIndexDefinitionBuilder defnb){ defnb.build(createPath(indexPath)); } Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidatorTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidatorTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidatorTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/property/UniquenessConstraintValidatorTest.java Mon Jun 29 06:49:51 2020 @@ -20,7 +20,7 @@ package org.apache.jackrabbit.oak.plugins.index.lucene.property; import org.apache.jackrabbit.oak.api.CommitFailedException; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; import org.apache.jackrabbit.oak.plugins.index.search.PropertyUpdateCallback; @@ -42,7 +42,7 @@ import static org.junit.Assert.fail; public class UniquenessConstraintValidatorTest { private NodeState root = INITIAL_CONTENT; private NodeBuilder builder = EMPTY_NODE.builder(); - private IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(); + private LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(); private String indexPath = "/oak:index/foo"; @Test Added: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneIndexDefinitionBuilderTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneIndexDefinitionBuilderTest.java?rev=1879319&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneIndexDefinitionBuilderTest.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneIndexDefinitionBuilderTest.java Mon Jun 29 06:49:51 2020 @@ -0,0 +1,991 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.jackrabbit.oak.plugins.index.lucene.util; + +import java.util.Iterator; + +import com.google.common.collect.Iterables; +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Root; +import org.apache.jackrabbit.oak.api.Tree; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.core.ImmutableRoot; +import org.apache.jackrabbit.oak.plugins.index.IndexConstants; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory; +import org.apache.jackrabbit.oak.spi.filter.PathFilter; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; +import org.hamcrest.Matchers; +import org.junit.After; +import org.junit.Test; + +import static com.google.common.collect.ImmutableList.of; +import static java.util.Arrays.asList; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEPRECATED; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_TAGS; +import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.AGGREGATES; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.FIELD_BOOST; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_FACETS; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_REFRESH_DEFN; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.COST_PER_ENTRY; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.COST_PER_EXECUTION; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.BLOB_SIZE; +import static org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants.PROP_WEIGHT; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; +import static org.junit.Assert.*; + +public class LuceneIndexDefinitionBuilderTest { + private LuceneIndexDefinitionBuilder builder = new LuceneIndexDefinitionBuilder(); + private NodeBuilder nodeBuilder = EMPTY_NODE.builder(); + + @After + public void dumpState(){ + System.out.println(NodeStateUtils.toString(builder.build())); + } + + @Test + public void defaultSetup() throws Exception{ + NodeState state = builder.build(); + assertEquals(2, state.getLong("compatVersion")); + assertEquals("async", state.getString("async")); + assertEquals("lucene", state.getString("type")); + } + + @Test + public void indexRule() throws Exception{ + builder.includedPaths("/a", "/b"); + builder.queryPaths("/c", "/d"); + builder.supersedes("/e", "/f"); + builder.indexRule("nt:base") + .property("foo") + .ordered() + .enclosingRule() + .property("bar") + .analyzed() + .propertyIndex() + .enclosingRule() + .property("baz") + .propertyIndex(); + + NodeState state = builder.build(); + assertTrue(state.getChildNode("indexRules").exists()); + assertTrue(state.getChildNode("indexRules").getChildNode("nt:base").exists()); + assertEquals(asList("/a", "/b"), state.getProperty(PathFilter.PROP_INCLUDED_PATHS).getValue(Type.STRINGS)); + assertEquals(asList("/c", "/d"), state.getProperty(IndexConstants.QUERY_PATHS).getValue(Type.STRINGS)); + assertEquals(asList("/e", "/f"), state.getProperty(IndexConstants.SUPERSEDED_INDEX_PATHS).getValue(Type.STRINGS)); + } + + @Test + public void propertyDefIndexPropertySetIndexFalse() throws Exception { + builder.indexRule("nt:base") + .property("foo") + .disable(); + + PropertyState state = builder.build(). + getChildNode("indexRules"). + getChildNode("nt:base"). + getChildNode("properties"). + getChildNode("foo"). + getProperty("index"); + + assertNotNull("index property must exist", state); + assertFalse("Incorrect default value of index property", state.getValue(Type.BOOLEAN)); + } + + @Test + public void aggregates() throws Exception{ + builder.aggregateRule("cq:Page").include("jcr:content").relativeNode(); + builder.aggregateRule("dam:Asset", "*", "*/*"); + + NodeState state = builder.build(); + assertTrue(state.getChildNode("aggregates").exists()); + assertTrue(state.getChildNode("aggregates").getChildNode("dam:Asset").exists()); + assertTrue(state.getChildNode("aggregates").getChildNode("cq:Page").exists()); + } + + @Test + public void duplicatePropertyName() throws Exception{ + builder.indexRule("nt:base") + .property("foo") + .ordered() + .enclosingRule() + .property("jcr:content/foo") + .analyzed() + .propertyIndex() + .enclosingRule() + .property("metadata/content/foo") + .propertyIndex(); + + NodeState state = builder.build(); + assertTrue(state.getChildNode("indexRules").exists()); + assertTrue(state.getChildNode("indexRules").getChildNode("nt:base").exists()); + assertEquals(3, state.getChildNode("indexRules").getChildNode("nt:base") + .getChildNode("properties").getChildNodeCount(10)); + } + + @Test + public void ruleOrder() throws Exception{ + builder.indexRule("nt:unstructured"); + builder.indexRule("nt:base"); + + Tree tree = TreeFactory.createTree(EMPTY_NODE.builder()); + builder.build(tree); + + //Assert the order + Iterator<Tree> children = tree.getChild("indexRules").getChildren().iterator(); + assertEquals("nt:unstructured", children.next().getName()); + assertEquals("nt:base", children.next().getName()); + } + + @Test + public void regexProperty() throws Exception{ + builder.indexRule("nt:base") + .property(FulltextIndexConstants.REGEX_ALL_PROPS, true); + + NodeState state = builder.build(); + assertTrue(NodeStateUtils.getNode(state, "indexRules/nt:base/properties/prop") + .getBoolean(FulltextIndexConstants.PROP_IS_REGEX)); + } + + @Test + public void mergeExisting() throws Exception{ + nodeBuilder.setProperty("foo", "bar"); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + NodeState state = builder.build(); + assertEquals("bar", state.getString("foo")); + assertEquals("async", state.getString("async")); + } + + @Test + public void mergeExisting_IndexRule() throws Exception{ + builder.indexRule("nt:unstructured").property("foo").propertyIndex(); + + nodeBuilder = builder.build().builder(); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + assertTrue(builder.hasIndexRule("nt:unstructured")); + assertFalse(builder.hasIndexRule("nt:base")); + + builder.indexRule("nt:unstructured").property("bar").propertyIndex(); + builder.indexRule("nt:base"); + + assertTrue(builder.indexRule("nt:unstructured").hasPropertyRule("foo")); + assertTrue(builder.indexRule("nt:unstructured").hasPropertyRule("bar")); + } + + @Test + public void mergeExisting_Aggregates() throws Exception{ + builder.aggregateRule("foo").include("/path1"); + builder.aggregateRule("foo").include("/path2"); + + nodeBuilder = builder.build().builder(); + + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.aggregateRule("foo").include("/path1"); + builder.aggregateRule("foo").include("/path3"); + + NodeState state = builder.build(); + assertEquals(3, state.getChildNode(AGGREGATES).getChildNode("foo").getChildNodeCount(100)); + } + + @Test + public void noReindexIfNoChange() throws Exception{ + builder.includedPaths("/a", "/b"); + builder.indexRule("nt:base") + .property("foo") + .ordered(); + + nodeBuilder = builder.build().builder(); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.includedPaths("/a", "/b"); + + assertFalse(builder.isReindexRequired()); + NodeState state = builder.build(); + assertFalse(state.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(state.getBoolean(PROP_REFRESH_DEFN)); + + + NodeState baseState = builder.build(); + nodeBuilder = baseState.builder(); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.indexRule("nt:file"); + + assertTrue(builder.isReindexRequired()); + state = builder.build(); + assertTrue(state.getBoolean(REINDEX_PROPERTY_NAME)); + + builder = new LuceneIndexDefinitionBuilder(baseState.builder(), false); + builder.indexRule("nt:file"); + assertTrue(builder.isReindexRequired()); + state = builder.build(); + assertTrue(builder.isReindexRequired()); + assertFalse(state.getBoolean(REINDEX_PROPERTY_NAME)); + } + + @Test + public void reindexAndAsyncFlagChange() throws Exception{ + builder.async("async", IndexConstants.INDEXING_MODE_NRT); + + nodeBuilder = builder.build().builder(); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + + NodeState oldState = nodeBuilder.getNodeState(); + + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.async("async", IndexConstants.INDEXING_MODE_SYNC); + assertFalse(builder.build().getBoolean(REINDEX_PROPERTY_NAME)); + + builder = new LuceneIndexDefinitionBuilder(oldState.builder()); + builder.async("fulltext-async", IndexConstants.INDEXING_MODE_SYNC); + assertTrue(builder.build().getBoolean(REINDEX_PROPERTY_NAME)); + } + + @Test + public void noReindexWhenIfQueryPathsAddedOrChanged() { + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.queryPaths("/a","/b"); + + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.queryPaths("/a","/c"); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().removeProperty(IndexConstants.QUERY_PATHS); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenIfIndexTagsAddedOrChanged() { + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.tags("foo1", "foo2"); + + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.tags("foo2", "foo3"); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.addTags("foo2"); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().removeProperty(IndexConstants.INDEX_TAGS); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenIfBlobSizeAddedOrChanged() { + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().setProperty(BLOB_SIZE,32768); + + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().setProperty(BLOB_SIZE,35768); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().removeProperty(BLOB_SIZE); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + // This property is used in cost estimation - no reindexing required + // on property change + @Test + public void noReindexIfWeightPropertyAddedOrChanged() throws Exception { + + builder.indexRule("nt:base").property("fooProp"); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + // Add the property weight to fooProp - this shouldn't cause reindex flag to set + builder.indexRule("nt:base").property("fooProp").weight(10); + + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + // Now change the value for weight on fooProp - this also shouldn't lead to setting of reindex flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.indexRule("nt:base").property("fooProp").weight(20); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.indexRule("nt:base").property("fooProp").getBuilderTree().removeProperty(PROP_WEIGHT); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + } + // modifying boost value shouldn't require reindexing because we use + // QueryTime Boosts and not index time boosts. Refer OAK-3367 for details + @Test + public void noReindexIfBoostPropAddedOrChanged() throws Exception { + builder.indexRule("nt:base").property("fooProp"); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + // Add the property boost - this shouldn't cause reindex flag to set + builder.indexRule("nt:base").property("fooProp").boost(1.0f); + + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + // Now change the value for boost - this also shouldn't lead to setting of reindex flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.indexRule("nt:base").property("fooProp").boost(2.0f); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.indexRule("nt:base").property("fooProp").getBuilderTree().removeProperty(FIELD_BOOST); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + } + + @Test + public void noReindexOnUseIfExists() throws Exception { + builder.indexRule("nt:base").property("foo1"); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + // Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + // Add the "useIfExists" property + builder.getBuilderTree().setProperty(IndexConstants.USE_IF_EXISTS, "/oak:index"); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + // Now test deleting the flag - should also not set the reindexing flag + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().removeProperty(IndexConstants.USE_IF_EXISTS); + + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + // This is a node for configuration on how faceted search works + // Everything impacts querty time evauation - so no need of reindexing in case of changes + @Test + public void noReindexWhenFacetNodeAddedOrRemoved() throws Exception { + builder.indexRule("nt:base") + .property("foo1").facets(); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + //Add the facets child node now + builder.getBuilderTree().addChild(PROP_FACETS); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + // Now test deleting the facets node should also not set the reindexing flag + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild(PROP_FACETS).remove(); + + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenFacetConfigChanged_topChildren() throws Exception { + builder.indexRule("nt:base") + .property("foo1").facets(); + + builder.getBuilderTree().addChild(PROP_FACETS); + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + //Add top Children prop on facets node + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_FACETS_TOP_CHILDREN,100); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + nodeBuilder = currentNodeState.builder(); + + //Now test with changing the value - this too shouldn't set the reindexing flag + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_FACETS_TOP_CHILDREN,200); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild(PROP_FACETS).removeProperty(FulltextIndexConstants.PROP_FACETS_TOP_CHILDREN); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenFacetConfigChanged_secure() throws Exception { + builder.indexRule("nt:base") + .property("foo1").facets(); + + builder.getBuilderTree().addChild(PROP_FACETS); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + //Add top secure prop on facets node + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_SECURE_FACETS,FulltextIndexConstants.PROP_SECURE_FACETS_VALUE_SECURE); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + //Now test with changing the value - this too shouldn't set the reindexing flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_SECURE_FACETS,FulltextIndexConstants.PROP_SECURE_FACETS_VALUE_INSECURE); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild(PROP_FACETS).removeProperty(FulltextIndexConstants.PROP_SECURE_FACETS); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenFacetConfigChanged_sampleSize() throws Exception { + builder.indexRule("nt:base") + .property("foo1").facets(); + + builder.getBuilderTree().addChild(PROP_FACETS); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + //Add top sample size prop on facets node + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE,1000); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + //Now test with changing the value - this too shouldn't set the reindexing flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE,2000); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild(PROP_FACETS).removeProperty(FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void noReindexWhenIfCostPerExecAddedOrChanged() { + builder.indexRule("nt:base"); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").setProperty(COST_PER_EXECUTION, 2.0); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + //Now test with changing the value - this too shouldn't set the reindexing flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").setProperty(COST_PER_EXECUTION, 3.0); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").removeProperty(COST_PER_EXECUTION); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + } + + @Test + public void noReindexWhenIfCostPerEntryAddedOrChanged() { + builder.indexRule("nt:base"); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").setProperty(COST_PER_ENTRY, 2.0); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + + //Now test with changing the value - this too shouldn't set the reindexing flag + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").setProperty(COST_PER_ENTRY, 3.0); + currentNodeState = builder.build(); + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //Now check for property delete use case + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().getChild("indexRules").getChild("nt:base").removeProperty(COST_PER_ENTRY); + currentNodeState = builder.build(); + + assertFalse(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertTrue(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + } + + @Test + public void reindexFlagSetWhenRequired() { + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.includedPaths("/a", "/b"); + + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.includedPaths("/a", "/c"); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + builder.getBuilderTree().removeProperty(PathFilter.PROP_INCLUDED_PATHS); + currentNodeState = builder.build(); + + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + } + + @Test + public void renidexIfFacetsNodeAddedwithSomeNewPropThatReqIndexing() throws Exception { + builder.indexRule("nt:base") + .property("foo1").facets(); + + NodeState currentNodeState = builder.build(); + nodeBuilder = currentNodeState.builder(); + + //Unset the reindex flag first because first build would have set it . + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().addChild(PROP_FACETS); + + //Add foo prop on facets node + builder.getBuilderTree().getChild(PROP_FACETS).setProperty("foo","bar"); + currentNodeState = builder.build(); + + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + nodeBuilder = currentNodeState.builder(); + + //Now test with changing the value - this too should set the reindexing flag + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild(PROP_FACETS).setProperty("foo","bar2"); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + //now deleting the node + nodeBuilder = currentNodeState.builder(); + nodeBuilder.removeProperty(PROP_REFRESH_DEFN); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().getChild(PROP_FACETS).remove(); + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + nodeBuilder = currentNodeState.builder(); + nodeBuilder.setProperty(REINDEX_PROPERTY_NAME, false); + builder = new LuceneIndexDefinitionBuilder(nodeBuilder); + + builder.getBuilderTree().addChild(PROP_FACETS); + + //Add foo prop on facets node + builder.getBuilderTree().getChild(PROP_FACETS).setProperty("foo","bar"); + builder.getBuilderTree().getChild(PROP_FACETS).setProperty(FulltextIndexConstants.PROP_STATISTICAL_FACET_SAMPLE_SIZE,200); + + currentNodeState = builder.build(); + assertTrue(currentNodeState.getBoolean(REINDEX_PROPERTY_NAME)); + assertFalse(currentNodeState.getBoolean(PROP_REFRESH_DEFN)); + + } + + @Test + public void propRuleCustomName() throws Exception{ + builder.indexRule("nt:base").property("foo").property("bar"); + builder.indexRule("nt:base").property("fooProp", "foo2"); + builder.indexRule("nt:base").property("fooProp", "foo2"); + + Root idx = new ImmutableRoot(builder.build()); + assertTrue(idx.getTree("/indexRules/nt:base/properties/fooProp").exists()); + assertTrue(idx.getTree("/indexRules/nt:base/properties/bar").exists()); + assertTrue(idx.getTree("/indexRules/nt:base/properties/foo").exists()); + } + + @Test + public void typeNotChangedIfSet() throws Exception{ + NodeState state = builder.build(); + assertEquals("lucene", state.getString("type")); + + NodeBuilder updated = state.builder(); + updated.setProperty("type", "disabled"); + LuceneIndexDefinitionBuilder newBuilder = new LuceneIndexDefinitionBuilder(updated); + + NodeState updatedState = newBuilder.build(); + assertEquals("disabled", updatedState.getString("type")); + + //Type other than 'disabled' would be reset + updated.setProperty("type", "foo"); + assertEquals("lucene", new LuceneIndexDefinitionBuilder(updated).build().getString("type")); + } + + @Test + public void nodeTypeIndex() throws Exception{ + builder.nodeTypeIndex(); + builder.indexRule("nt:file"); + + NodeState state = builder.build(); + assertTrue(state.getChildNode("indexRules").exists()); + NodeState ntFileRule = state.getChildNode("indexRules").getChildNode("nt:file"); + assertTrue(ntFileRule.exists()); + assertTrue(state.getBoolean(FulltextIndexConstants.PROP_INDEX_NODE_TYPE)); + assertFalse(ntFileRule.getBoolean(FulltextIndexConstants.PROP_SYNC)); + } + + @Test + public void nodeTypeIndexSync() throws Exception{ + builder.nodeTypeIndex(); + builder.indexRule("nt:file").sync(); + + NodeState state = builder.build(); + assertTrue(state.getChildNode("indexRules").exists()); + NodeState ntFileRule = state.getChildNode("indexRules").getChildNode("nt:file"); + assertTrue(ntFileRule.exists()); + assertTrue(state.getBoolean(FulltextIndexConstants.PROP_INDEX_NODE_TYPE)); + assertTrue(ntFileRule.getBoolean(FulltextIndexConstants.PROP_SYNC)); + } + + @Test + public void noPropertiesNodeForEmptyRule() throws Exception{ + builder.nodeTypeIndex(); + builder.indexRule("nt:file").sync(); + + NodeState state = builder.build(); + assertFalse(NodeStateUtils.getNode(state, "/indexRules/nt:file/properties").exists()); + } + + @Test + public void deprecated() { + NodeState state = builder.build(); + assertFalse("By default index isn't deprecated", state.getBoolean(INDEX_DEPRECATED)); + + state = builder.deprecated().build(); + assertTrue("Index must be deprecated if marked so", state.getBoolean(INDEX_DEPRECATED)); + } + + @Test + public void boost() { + builder.indexRule("nt:base") + .property("foo1").boost(1.0f).enclosingRule() + .property("foo2").boost(2.0f); + + NodeState state = builder.build(); + + NodeState foo1 = NodeStateUtils.getNode(state, "indexRules/nt:base/properties/foo1"); + assertTrue(foo1.exists()); + assertEquals("Incorrectly set boost", + 1.0f, foo1.getProperty(FIELD_BOOST).getValue(Type.DOUBLE).floatValue(), 0.0001); + + NodeState foo2 = NodeStateUtils.getNode(state, "indexRules/nt:base/properties/foo2"); + assertTrue(foo2.exists()); + assertEquals("Incorrectly set boost", + 2.0f, foo2.getProperty(FIELD_BOOST).getValue(Type.DOUBLE).floatValue(), 0.0001); + } + + @Test + public void facets() { + builder.indexRule("nt:base") + .property("foo1").facets().enclosingRule() + .property("foo2").propertyIndex(); + + NodeState state = builder.build(); + + NodeState foo1 = NodeStateUtils.getNode(state, "indexRules/nt:base/properties/foo1"); + assertTrue(foo1.exists()); + assertTrue("Incorrectly set facets property", + foo1.getBoolean(PROP_FACETS)); + + NodeState foo2 = NodeStateUtils.getNode(state, "indexRules/nt:base/properties/foo2"); + assertTrue(foo2.exists()); + assertFalse("Incorrectly existing facets property", + foo2.hasProperty(PROP_FACETS)); + } + + @Test + public void tags() { + NodeState state = EMPTY_NODE; + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.tags("foo"); + state = builder.build(); + Iterable<String> tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 1, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo")); + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.addTags("foo"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 1, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo")); + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.addTags("foo", "foo1"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 2, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo", "foo1")); + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.addTags("foo2"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 3, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo", "foo1", "foo2")); + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.addTags("foo2", "foo3"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 4, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo", "foo1", "foo2", "foo3")); + + builder = new LuceneIndexDefinitionBuilder(state.builder()); + builder.tags("foo4"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 1, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo4")); + + builder = new LuceneIndexDefinitionBuilder(EMPTY_NODE.builder()); + builder.addTags("foo5"); + state = builder.build(); + tags = state.getProperty(INDEX_TAGS).getValue(Type.STRINGS); + assertEquals("Unexpected number of tags", 1, Iterables.size(tags)); + assertThat(state.getProperty(INDEX_TAGS).getValue(Type.STRINGS), + Matchers.containsInAnyOrder("foo5")); + } + + @Test + public void unnamedPropertyRuleInExistingIndex() { + // create an initial index with property rule for "foo" + builder + .indexRule("nt:base") + .property("foo") + // remove "name" property explicitly + .getBuilderTree().removeProperty("name"); + NodeState initialIndexState = builder.build(); + + // Use initial index def to add some other property rule - this should work + new LuceneIndexDefinitionBuilder(initialIndexState.builder()) + .indexRule("nt:base") + .property("bar"); + } +} \ No newline at end of file Propchange: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/util/LuceneIndexDefinitionBuilderTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/FailedIndexUpdateTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/FailedIndexUpdateTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/FailedIndexUpdateTest.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/writer/FailedIndexUpdateTest.java Mon Jun 29 06:49:51 2020 @@ -37,7 +37,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.CopyOnWriteDirectory; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore; import org.apache.jackrabbit.oak.spi.commit.*; import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider; @@ -212,7 +212,7 @@ public class FailedIndexUpdateTest { } private void createIndex(String idxName, String propName, boolean shouldFail) throws CommitFailedException { - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); idxBuilder .includedPaths(TEST_CONTENT_PATH) Modified: jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/HybridIndexDisabledTest.groovy URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/HybridIndexDisabledTest.groovy?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/HybridIndexDisabledTest.groovy (original) +++ jackrabbit/oak/trunk/oak-pojosr/src/test/groovy/org/apache/jackrabbit/oak/run/osgi/HybridIndexDisabledTest.groovy Mon Jun 29 06:49:51 2020 @@ -21,7 +21,7 @@ package org.apache.jackrabbit.oak.run.os import org.apache.felix.connect.launch.PojoServiceRegistry import org.apache.jackrabbit.commons.JcrUtils -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer import org.apache.jackrabbit.oak.spi.state.NodeBuilder import org.junit.After @@ -75,7 +75,7 @@ class HybridIndexDisabledTest extends Ab if (builder.hasChildNode(INDEX_DEFINITIONS_NAME)) { NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME); - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); idxBuilder.async("async", "sync") idxBuilder.indexRule("nt:base").property("foo").propertyIndex() index.setChildNode("fooIndex", idxBuilder.build()) Modified: jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/AbstractIndexCommandTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/AbstractIndexCommandTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/AbstractIndexCommandTest.java (original) +++ jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/AbstractIndexCommandTest.java Mon Jun 29 06:49:51 2020 @@ -28,7 +28,7 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.apache.jackrabbit.oak.plugins.index.IndexConstants; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.junit.After; import org.junit.Rule; import org.junit.rules.TemporaryFolder; @@ -78,7 +78,7 @@ public class AbstractIndexCommandTest { } private void createLuceneIndex(boolean asyncIndex) throws IOException, RepositoryException { - IndexDefinitionBuilder idxBuilder = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxBuilder = new LuceneIndexDefinitionBuilder(); if (!asyncIndex) { idxBuilder.noAsync(); } Modified: jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java (original) +++ jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/DocumentStoreIndexerIT.java Mon Jun 29 06:49:51 2020 @@ -50,7 +50,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.document.util.Utils; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexDir; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.spi.commit.CommitInfo; import org.apache.jackrabbit.oak.spi.commit.EmptyHook; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -216,7 +216,7 @@ public class DocumentStoreIndexerIT exte NodeBuilder builder = store.getRoot().builder(); NodeBuilder idxb = childBuilder(builder, TEST_INDEX_PATH); - IndexDefinitionBuilder defnb = new IndexDefinitionBuilder(idxb); + LuceneIndexDefinitionBuilder defnb = new LuceneIndexDefinitionBuilder(idxb); defnb.indexRule("nt:base").property("foo").propertyIndex(); defnb.build(); Modified: jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java (original) +++ jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/ReindexIT.java Mon Jun 29 06:49:51 2020 @@ -21,7 +21,6 @@ package org.apache.jackrabbit.oak.index; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -44,7 +43,7 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.importer.ClusterNodeStoreLock; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.IndexRootDirectory; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.LocalIndexDir; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; @@ -311,7 +310,7 @@ public class ReindexIT extends AbstractI private void indexBarPropertyAlso(RepositoryFixture fixture2) throws IOException, RepositoryException { Session session = fixture2.getAdminSession(); NodeState idxState = NodeStateUtils.getNode(fixture2.getNodeStore().getRoot(), TEST_INDEX_PATH); - IndexDefinitionBuilder idxb = new IndexDefinitionBuilder( + LuceneIndexDefinitionBuilder idxb = new LuceneIndexDefinitionBuilder( new MemoryNodeBuilder(idxState), false); idxb.indexRule("nt:base").property("bar").propertyIndex(); Modified: jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/LuceneIndexerTest.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/LuceneIndexerTest.java?rev=1879319&r1=1879318&r2=1879319&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/LuceneIndexerTest.java (original) +++ jackrabbit/oak/trunk/oak-run/src/test/java/org/apache/jackrabbit/oak/index/indexer/document/LuceneIndexerTest.java Mon Jun 29 06:49:51 2020 @@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.index.indexer.document; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexDefinitionBuilder; import org.apache.jackrabbit.oak.plugins.index.lucene.writer.LuceneIndexWriter; import org.apache.jackrabbit.oak.plugins.index.progress.IndexingProgressReporter; import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; @@ -38,7 +38,7 @@ public class LuceneIndexerTest { @Test public void nodeIndexed_WithIncludedPaths() throws Exception{ - IndexDefinitionBuilder idxb = new IndexDefinitionBuilder(); + LuceneIndexDefinitionBuilder idxb = new LuceneIndexDefinitionBuilder(); idxb.indexRule("nt:base").property("foo").propertyIndex(); idxb.includedPaths("/content");
