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