Search in sources :

Example 16 with PropertyIndexLookup

use of org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup in project jackrabbit-oak by apache.

the class IndexUpdateTest method ignoreReindexingFlag.

@Test
public void ignoreReindexingFlag() throws Exception {
    String indexPath = "/oak:index/rootIndex";
    CallbackCapturingProvider provider = new CallbackCapturingProvider();
    IndexUpdateProvider indexUpdate = new IndexUpdateProvider(provider);
    EditorHook hook = new EditorHook(indexUpdate);
    NodeState before = builder.getNodeState();
    createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "rootIndex", true, false, ImmutableSet.of("foo"), null);
    builder.child("a").setProperty("foo", "abc");
    NodeState after = builder.getNodeState();
    NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    assertTrue(provider.getContext(indexPath).isReindexing());
    before = indexed;
    builder = before.builder();
    builder.child("b").setProperty("foo", "xyz");
    child(builder, indexPath).setProperty(IndexConstants.REINDEX_PROPERTY_NAME, true);
    after = builder.getNodeState();
    provider.reset();
    indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    assertTrue(provider.getContext(indexPath).isReindexing());
    // Now set IndexUpdate to ignore the reindex flag
    indexUpdate.setIgnoreReindexFlags(true);
    indexed = hook.processCommit(before, after, CommitInfo.EMPTY);
    assertFalse(provider.getContext(indexPath).isReindexing());
    // Despite reindex flag set to true and reindexing not done new
    // content should still get picked up
    PropertyIndexLookup lookup = new PropertyIndexLookup(indexed);
    assertFalse(find(lookup, "foo", "xyz").isEmpty());
}
Also used : EmptyNodeState(org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) EditorHook(org.apache.jackrabbit.oak.spi.commit.EditorHook) PropertyIndexLookup(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup) Test(org.junit.Test)

Aggregations

PropertyIndexLookup (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexLookup)16 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)15 Test (org.junit.Test)15 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)7 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)7 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)6 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)5 ProxyNodeStore (org.apache.jackrabbit.oak.spi.state.ProxyNodeStore)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)3 File (java.io.File)2 AsyncIndexUpdate (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate)2 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)2 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)2 IndexTaskSpliter (org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate.IndexTaskSpliter)1 CorruptIndexInfo (org.apache.jackrabbit.oak.plugins.index.TrackingCorruptIndexHandler.CorruptIndexInfo)1 Clock (org.apache.jackrabbit.oak.stats.Clock)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1