Search in sources :

Example 1 with IndexingRule

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

the class IndexDefinitionTest method indexRuleWithPropertyRegEx.

@Test
public void indexRuleWithPropertyRegEx() 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);
    TestUtil.child(rules, "nt:folder/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo.*").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"));
    assertFalse(rule1.isIndexed("prop2"));
    assertTrue(rule1.isIndexed("fooProp"));
    PropertyDefinition pd = rule1.getConfig("fooProp2");
    assertEquals(4.0f, pd.boost, 0);
}
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 2 with IndexingRule

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

the class IndexDefinitionTest method relativePropertyConfig.

@Test
public void relativePropertyConfig() throws Exception {
    builder.child(PROP_NODE).child("foo1").child("bar").setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_DATE);
    builder.child(PROP_NODE).child("foo2").child("bar2").child("baz").setProperty(LuceneIndexConstants.PROP_TYPE, PropertyType.TYPENAME_LONG);
    builder.setProperty(createProperty(INCLUDE_PROPERTY_NAMES, of("foo", "foo1/bar", "foo2/bar2/baz"), STRINGS));
    IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo");
    IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder")));
    assertNotNull(rule.getConfig("foo1/bar"));
    assertEquals(PropertyType.DATE, rule.getConfig("foo1/bar").getType());
    assertEquals(PropertyType.LONG, rule.getConfig("foo2/bar2/baz").getType());
    assertTrue(rule.getConfig("foo1/bar").relative);
    assertArrayEquals(new String[] { "foo2", "bar2" }, rule.getConfig("foo2/bar2/baz").ancestors);
}
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 3 with IndexingRule

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

Aggregations

IndexingRule (org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule)29 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)24 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)24 Test (org.junit.Test)24 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)13 IndexDefinitionBuilder (org.apache.jackrabbit.oak.plugins.index.lucene.util.IndexDefinitionBuilder)6 PropertyRestriction (org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction)2 FullTextTerm (org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm)2 PrefixQuery (org.apache.lucene.search.PrefixQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 WildcardQuery (org.apache.lucene.search.WildcardQuery)2 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 NodeDocument (org.apache.jackrabbit.oak.plugins.document.NodeDocument)1 LuceneDocumentMaker (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneDocumentMaker)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