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