Search in sources :

Example 81 with NodeBuilder

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

the class IndexDefinitionTest method analyzedEnabledForBoostedField.

@Test
public void analyzedEnabledForBoostedField() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    rules.child("nt:folder");
    TestUtil.child(rules, "nt:folder/properties/prop1").setProperty(LuceneIndexConstants.FIELD_BOOST, 3.0).setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true);
    TestUtil.child(rules, "nt:folder/properties/prop2").setProperty(LuceneIndexConstants.PROP_ANALYZED, true).setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true);
    TestUtil.child(rules, "nt:folder/properties/prop3").setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true).setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule1);
    PropertyDefinition pd = rule1.getConfig("prop1");
    assertEquals(3.0f, pd.boost, 0);
    assertTrue("Analyzed should be assumed to be true for boosted fields", pd.analyzed);
    assertFalse(rule1.getConfig("prop3").analyzed);
    assertEquals(2, rule1.getNodeScopeAnalyzedProps().size());
}
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 82 with NodeBuilder

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

the class IndexPlannerTest method planForSortField.

@Test
public void planForSortField() throws Exception {
    NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
    defn.setProperty(createProperty(ORDERED_PROP_NAMES, of("foo"), STRINGS));
    IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
    IndexPlanner planner = new IndexPlanner(node, "/foo", createFilter("nt:base"), ImmutableList.of(new OrderEntry("foo", Type.LONG, OrderEntry.Order.ASCENDING)));
    assertNotNull(planner.getPlan());
    assertTrue(pr(planner.getPlan()).isUniquePathsRequired());
}
Also used : OrderEntry(org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry) 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 83 with NodeBuilder

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

the class IndexPlannerTest method hasPathRestHasNoExplicitQueryPaths.

@Test
public void hasPathRestHasNoExplicitQueryPaths() throws Exception {
    NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
    IndexNode node = createIndexNode(new IndexDefinition(root, defn.getNodeState(), "/foo"));
    FilterImpl filter = createFilter("nt:base");
    filter.restrictPath("/test2", Filter.PathRestriction.ALL_CHILDREN);
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
    assertNotNull(planner.getPlan());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) 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 84 with NodeBuilder

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

the class IndexDefinitionTest method testSuggestDisabled.

@Test
public void testSuggestDisabled() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    TestUtil.child(rules, "oak:TestNode/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo");
    root = registerTestNodeType(builder).getNodeState();
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    assertFalse(idxDefn.isSuggestEnabled());
}
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 85 with NodeBuilder

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

the class IndexDefinitionTest method testSuggestEnabledOnNamedProp.

@Test
public void testSuggestEnabledOnNamedProp() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    TestUtil.child(rules, "oak:TestNode/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo").setProperty(LuceneIndexConstants.PROP_USE_IN_SUGGEST, true);
    root = registerTestNodeType(builder).getNodeState();
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    assertTrue(idxDefn.isSuggestEnabled());
}
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)

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