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"));
}
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"));
}
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);
}
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());
}
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());
}
Aggregations