Search in sources :

Example 6 with IndexingRule

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

the class IndexDefinitionTest method fullTextEnabled.

@Test
public void fullTextEnabled() throws Exception {
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = idxDefn.getApplicableIndexingRule(NT_BASE);
    assertTrue("By default fulltext is enabled", idxDefn.isFullTextEnabled());
    assertTrue("By default everything is indexed", rule.isIndexed("foo"));
    assertTrue("Property types need to be defined", rule.includePropertyType(PropertyType.DATE));
    assertTrue("For fulltext storage is enabled", rule.getConfig("foo").stored);
    assertFalse(rule.getConfig("foo").skipTokenization("foo"));
    assertTrue(rule.getConfig("jcr:uuid").skipTokenization("jcr:uuid"));
}
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 7 with IndexingRule

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

the class IndexDefinitionTest method propertyTypes.

@Test
public void propertyTypes() throws Exception {
    builder.setProperty(createProperty(INCLUDE_PROPERTY_TYPES, of(TYPENAME_LONG), STRINGS));
    builder.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo", "bar"), STRINGS));
    builder.setProperty(LuceneIndexConstants.FULL_TEXT_ENABLED, false);
    IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = idxDefn.getApplicableIndexingRule(NT_BASE);
    assertFalse(idxDefn.isFullTextEnabled());
    assertFalse("If fulltext disabled then nothing stored", rule.getConfig("foo").stored);
    assertTrue(rule.includePropertyType(PropertyType.LONG));
    assertFalse(rule.includePropertyType(PropertyType.STRING));
    assertTrue(rule.isIndexed("foo"));
    assertTrue(rule.isIndexed("bar"));
    assertFalse(rule.isIndexed("baz"));
    assertTrue(rule.getConfig("foo").skipTokenization("foo"));
}
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 8 with IndexingRule

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

the class IndexDefinitionTest method nonIndexPropShouldHaveAllOtherConfigDisabled.

@Test
public void nonIndexPropShouldHaveAllOtherConfigDisabled() 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_INDEX, false).setProperty(LuceneIndexConstants.PROP_USE_IN_SUGGEST, true).setProperty(LuceneIndexConstants.PROP_USE_IN_SPELLCHECK, true).setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true).setProperty(LuceneIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true).setProperty(LuceneIndexConstants.PROP_USE_IN_EXCERPT, true).setProperty(LuceneIndexConstants.PROP_NODE_SCOPE_INDEX, true).setProperty(LuceneIndexConstants.PROP_ORDERED, true).setProperty(LuceneIndexConstants.PROP_ANALYZED, true);
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule);
    PropertyDefinition pd = rule.getConfig("foo");
    //Assert that all other config is false if the index=false for any property
    assertFalse(pd.index);
    assertFalse(pd.nodeScopeIndex);
    assertFalse(pd.useInSuggest);
    assertFalse(pd.useInSpellcheck);
    assertFalse(pd.nullCheckEnabled);
    assertFalse(pd.notNullCheckEnabled);
    assertFalse(pd.stored);
    assertFalse(pd.ordered);
    assertFalse(pd.analyzed);
}
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 9 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule 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 10 with IndexingRule

use of org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule 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)

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