@Override protected void indexAnalyzedProperty(Document doc, String pname, String value, PropertyDefinition pd) { String analyzedPropName = constructAnalyzedPropertyName(pname); doc.add(newPropertyField(analyzedPropName, value, !pd.skipTokenization(pname), pd.stored)); }
@Override protected void indexAnalyzedProperty(Document doc, String pname, String value, PropertyDefinition pd) { String analyzedPropName = constructAnalyzedPropertyName(pname); doc.add(newPropertyField(analyzedPropName, value, !pd.skipTokenization(pname), pd.stored)); }
@Test public void fullTextEnabled() throws Exception{ IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo"); IndexDefinition.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")); }
@Test public void fullTextEnabled() throws Exception{ LuceneIndexDefinition idxDefn = new LuceneIndexDefinition(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")); }
@Test public void skipTokenization() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); rules.child("nt:folder"); TestUtil.child(rules, "nt:folder/properties/prop2") .setProperty(PROP_NAME, ".*") .setProperty(FulltextIndexConstants.PROP_IS_REGEX, true) .setProperty(FulltextIndexConstants.PROP_ANALYZED, true); IndexDefinition defn = new IndexDefinition(root, builder.getNodeState(), "/foo"); IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder"))); assertFalse(rule.getConfig("foo").skipTokenization("foo")); assertTrue(rule.getConfig(JcrConstants.JCR_UUID).skipTokenization(JcrConstants.JCR_UUID)); }
@Test public void skipTokenization() throws Exception{ NodeBuilder rules = builder.child(INDEX_RULES); rules.child("nt:folder"); TestUtil.child(rules, "nt:folder/properties/prop2") .setProperty(PROP_NAME, ".*") .setProperty(FulltextIndexConstants.PROP_IS_REGEX, true) .setProperty(FulltextIndexConstants.PROP_ANALYZED, true); LuceneIndexDefinition defn = new LuceneIndexDefinition(root, builder.getNodeState(), "/foo"); IndexingRule rule = defn.getApplicableIndexingRule(asState(newNode("nt:folder"))); assertFalse(rule.getConfig("foo").skipTokenization("foo")); assertTrue(rule.getConfig(JcrConstants.JCR_UUID).skipTokenization(JcrConstants.JCR_UUID)); }
@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(FULL_TEXT_ENABLED, false); LuceneIndexDefinition idxDefn = new LuceneIndexDefinition(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")); }
@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(FulltextIndexConstants.FULL_TEXT_ENABLED, false); IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState(), "/foo"); IndexDefinition.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")); }