Search in sources :

Example 16 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule in project jackrabbit-oak by apache.

the class IndexDefinitionTest method propertyDefinition.

@Test
public void propertyDefinition() throws Exception {
    builder.child(PROP_NODE).child("foo").setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE);
    builder.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo", "bar"), STRINGS));
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = idxDefn.getApplicableIndexingRule(NT_BASE);
    assertTrue(rule.isIndexed("foo"));
    assertTrue(rule.isIndexed("bar"));
    assertEquals(PropertyType.DATE, rule.getConfig("foo").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) Test(org.junit.Test)

Example 17 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule in project jackrabbit-oak by apache.

the class IndexDefinitionTest method nodeFullTextIndexed_Simple.

@Test
public void nodeFullTextIndexed_Simple() 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);
    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 18 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule in project jackrabbit-oak by apache.

the class IndexDefinitionTest method formatUpdate.

@Test
public void formatUpdate() throws Exception {
    NodeBuilder defnb = newLuceneIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", of(TYPENAME_STRING), of("foo", "Bar"), "async");
    IndexDefinition defn = new IndexDefinition(root, defnb.getNodeState(), "/foo");
    assertTrue(defn.isOfOldFormat());
    NodeBuilder updated = IndexDefinition.updateDefinition(defnb.getNodeState().builder());
    IndexDefinition defn2 = new IndexDefinition(root, updated.getNodeState(), "/foo");
    assertFalse(defn2.isOfOldFormat());
    IndexingRule rule = defn2.getApplicableIndexingRule(asState(newNode("nt:base")));
    assertNotNull(rule);
    assertFalse(rule.getConfig("foo").index);
    assertFalse(rule.getConfig("Bar").index);
}
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 19 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule in project jackrabbit-oak by apache.

the class IndexDefinitionTest method indexRuleWithPropertyRegEx2.

@Test
public void indexRuleWithPropertyRegEx2() 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_IS_REGEX, true);
    TestUtil.child(rules, "nt:folder/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "metadata/.*").setProperty(LuceneIndexConstants.PROP_IS_REGEX, true).setProperty(LuceneIndexConstants.FIELD_BOOST, 4.0);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule1);
    assertTrue(rule1.isIndexed("prop1"));
    assertTrue(rule1.isIndexed("prop2"));
    assertFalse(rule1.isIndexed("jcr:content/prop1"));
    assertTrue(rule1.isIndexed("metadata/foo"));
    assertFalse(rule1.isIndexed("metadata/foo/bar"));
}
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 20 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule in project jackrabbit-oak by apache.

the class IndexDefinitionTest method propertyConfigCaseInsensitive.

@Test
public void propertyConfigCaseInsensitive() throws Exception {
    NodeBuilder rules = builder.child(INDEX_RULES);
    rules.child("nt:folder");
    TestUtil.child(rules, "nt:folder/properties/foo").setProperty(LuceneIndexConstants.PROP_NAME, "Foo").setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true);
    TestUtil.child(rules, "nt:folder/properties/bar").setProperty(LuceneIndexConstants.PROP_NAME, "BAR").setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule1 = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule1);
    assertTrue(rule1.isIndexed("Foo"));
    assertTrue(rule1.isIndexed("foo"));
    assertTrue(rule1.isIndexed("fOO"));
    assertTrue(rule1.isIndexed("bar"));
    assertFalse(rule1.isIndexed("baz"));
}
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

IndexingRule (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule)22 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)18 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)18 Test (org.junit.Test)18 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)13 FullTextTerm (org.apache.jackrabbit.oak.query.fulltext.FullTextTerm)2 PropertyRestriction (org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction)2 PrefixQuery (org.apache.lucene.search.PrefixQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 WildcardQuery (org.apache.lucene.search.WildcardQuery)2 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 TermFactory.newFulltextTerm (org.apache.jackrabbit.oak.plugins.index.lucene.TermFactory.newFulltextTerm)1 TermFactory.newPathTerm (org.apache.jackrabbit.oak.plugins.index.lucene.TermFactory.newPathTerm)1 FullTextContains (org.apache.jackrabbit.oak.query.fulltext.FullTextContains)1 FullTextExpression (org.apache.jackrabbit.oak.query.fulltext.FullTextExpression)1 FullTextVisitor (org.apache.jackrabbit.oak.query.fulltext.FullTextVisitor)1 IndexPlan (org.apache.jackrabbit.oak.spi.query.QueryIndex.IndexPlan)1 OrderEntry (org.apache.jackrabbit.oak.spi.query.QueryIndex.OrderEntry)1