Search in sources :

Example 86 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method notNullCheckEnabledWithTestNode.

@Test
public void notNullCheckEnabledWithTestNode() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    TestUtil.child(rules, "oak:TestNode/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo").setProperty(LuceneIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true);
    root = registerTestNodeType(builder).getNodeState();
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    assertTrue(!idxDefn.getApplicableIndexingRule(TestUtil.NT_TEST).getNotNullCheckEnabledProperties().isEmpty());
}
Also used : LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 87 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method nodeFullTextIndexed_Regex.

@Test
public void nodeFullTextIndexed_Regex() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    rules.child("nt:folder");
    TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.PROP_NAME, ".*").setProperty(LuceneIndexConstants.PROP_ANALYZED, true).setProperty(LuceneIndexConstants.PROP_IS_REGEX, true);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule);
    assertFalse(rule.isNodeFullTextIndexed());
    TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true);
    defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertTrue(rule.isNodeFullTextIndexed());
    assertTrue(rule.indexesAllNodesOfMatchingType());
}
Also used : IndexingRule(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 88 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method versionFreshIsCurrent.

@Test
public void versionFreshIsCurrent() throws Exception {
    NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING));
    IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertEquals(IndexFormatVersion.getDefault(), defn.getVersion());
}
Also used : LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 89 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method indexRuleSanity.

@Test
public void indexRuleSanity() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    rules.child("nt:folder").setProperty(LuceneIndexConstants.FIELD_BOOST, 2.0);
    TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.FIELD_BOOST, 3.0).setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_BOOLEAN);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    assertNull(defn.getApplicableIndexingRule(asState(newNode("nt:base"))));
    IndexingRule rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule1);
    assertEquals(2.0f, rule1.boost, 0);
    assertTrue(rule1.isIndexed("prop1"));
    assertFalse(rule1.isIndexed("prop2"));
    PropertyDefinition pd = rule1.getConfig("prop1");
    assertEquals(3.0f, pd.boost, 0);
    assertEquals(PropertyType.BOOLEAN, pd.getType());
}
Also used : IndexingRule(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Example 90 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class IndexDefinitionTest method nodeFullTextIndexed_Aggregates.

@Test
public void nodeFullTextIndexed_Aggregates() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    rules.child("nt:folder");
    TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.PROP_NAME, "foo").setProperty(LuceneIndexConstants.PROP_ANALYZED, true);
    NodeBuilder aggregates = builder.child(LuceneIndexConstants.AGGREGATES);
    NodeBuilder aggFolder = aggregates.child("nt:folder");
    aggFolder.child("i1").setProperty(LuceneIndexConstants.AGG_PATH, "*");
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule);
    assertTrue(rule.isNodeFullTextIndexed());
    assertTrue(rule.indexesAllNodesOfMatchingType());
}
Also used : IndexingRule(org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule) LuceneIndexHelper.newLucenePropertyIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition) LuceneIndexHelper.newLuceneIndexDefinition(org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Test(org.junit.Test)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26