Search in sources :

Example 6 with IndexConfig

use of com.enonic.xp.index.IndexConfig in project xp by enonic.

the class IndexItemFactory method createItems.

private static List<IndexItem> createItems(final IndexPath indexPath, final IndexConfigDocument indexConfigDocument, final Value processedPropertyValue) {
    final List<IndexItem> items = new ArrayList<>();
    final IndexConfig indexConfig = indexConfigDocument.getConfigForPath(indexPath);
    if (indexConfig.isEnabled()) {
        items.addAll(BaseTypeFactory.create(indexPath, processedPropertyValue));
        items.addAll(FulltextTypeFactory.create(indexPath, processedPropertyValue, indexConfig));
        items.add(OrderByTypeFactory.create(indexPath, processedPropertyValue));
        items.addAll(AllTextTypeFactory.create(processedPropertyValue, indexConfig, indexConfigDocument.getAllTextConfig()));
        items.addAll(StemmedTypeFactory.create(indexPath, processedPropertyValue, indexConfig));
        if (indexConfig.isPath()) {
            items.add(PathTypeFactory.create(indexPath, processedPropertyValue));
        }
    }
    return items;
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig) ArrayList(java.util.ArrayList)

Example 7 with IndexConfig

use of com.enonic.xp.index.IndexConfig in project xp by enonic.

the class DumpServiceImplTest method checkLanguageUpgrade.

private void checkLanguageUpgrade(final Node draftNode) {
    final IndexConfig indexConfigBefore = draftNode.getIndexConfigDocument().getConfigForPath(PropertyPath.from("language"));
    final List<String> languages = draftNode.getIndexConfigDocument().getAllTextConfig().getLanguages();
    assertEquals(IndexConfig.NGRAM, indexConfigBefore);
    assertEquals(1, languages.size());
    assertEquals("no", languages.get(0));
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig)

Example 8 with IndexConfig

use of com.enonic.xp.index.IndexConfig in project xp by enonic.

the class IndexConfigFactory method createPathConfigs.

private void createPathConfigs(final PatternIndexConfigDocument.Builder builder) {
    final Iterable<PropertySet> pathConfigs = this.propertySet.getSets(CONFIG_ARRAY);
    if (pathConfigs == null) {
        return;
    }
    for (final PropertySet pathConfig : pathConfigs) {
        final String path = pathConfig.getString(CONFIG_PATH);
        final IndexConfig config = createConfig(pathConfig.getProperty(CONFIG_SETTINGS));
        builder.add(path, config);
    }
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig) PropertySet(com.enonic.xp.data.PropertySet)

Example 9 with IndexConfig

use of com.enonic.xp.index.IndexConfig in project xp by enonic.

the class IndexConfigFactory method create.

private IndexConfig create(final PropertySet settings) {
    final Boolean decideByType = settings.getBoolean("decideByType");
    final Boolean enabled = settings.getBoolean("enabled");
    final Boolean nGram = settings.getBoolean("nGram");
    final Boolean fulltext = settings.getBoolean("fulltext");
    final Boolean includeInAllText = settings.getBoolean("includeInAllText");
    final Boolean path = settings.getBoolean("path");
    final Iterable<String> indexValueProcessors = settings.getStrings("indexValueProcessors");
    final Iterable<String> languages = settings.getStrings("languages");
    final IndexConfig.Builder builder = IndexConfig.create().decideByType(decideByType != null ? decideByType : false).enabled(enabled != null ? enabled : true).nGram(nGram != null ? nGram : false).fulltext(fulltext != null ? fulltext : false).includeInAllText(includeInAllText != null ? includeInAllText : false).path(path != null ? path : false);
    for (final String indexValueProcessorName : indexValueProcessors) {
        final IndexValueProcessor indexValueProcessor = IndexValueProcessors.get(indexValueProcessorName);
        if (indexValueProcessor != null) {
            builder.addIndexValueProcessor(indexValueProcessor);
        }
    }
    for (final String language : languages) {
        builder.addLanguage(language);
    }
    return builder.build();
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig) IndexValueProcessor(com.enonic.xp.index.IndexValueProcessor)

Example 10 with IndexConfig

use of com.enonic.xp.index.IndexConfig in project xp by enonic.

the class IndexConfigVisitor method visit.

@Override
public void visit(final Input input) {
    if (InputTypeName.HTML_AREA.equals(input.getInputType())) {
        final IndexConfig htmlIndexConfig = IndexConfig.create().enabled(true).fulltext(true).nGram(true).decideByType(false).includeInAllText(true).addIndexValueProcessor(IndexValueProcessors.HTML_STRIPPER).build();
        configDocumentBuilder.add(createPath(input), htmlIndexConfig);
    }
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig)

Aggregations

IndexConfig (com.enonic.xp.index.IndexConfig)11 PathIndexConfig (com.enonic.xp.index.PathIndexConfig)3 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)3 PropertySet (com.enonic.xp.data.PropertySet)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 IndexValueProcessor (com.enonic.xp.index.IndexValueProcessor)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 AccessControlEntry (com.enonic.xp.security.acl.AccessControlEntry)2 AccessControlList (com.enonic.xp.security.acl.AccessControlList)2 Test (org.junit.jupiter.api.Test)2 Property (com.enonic.xp.data.Property)1 PropertyVisitor (com.enonic.xp.data.PropertyVisitor)1 Value (com.enonic.xp.data.Value)1 IndexConfigDocument (com.enonic.xp.index.IndexConfigDocument)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 PrincipalKey (com.enonic.xp.security.PrincipalKey)1 Permission (com.enonic.xp.security.acl.Permission)1 DomElement (com.enonic.xp.xml.DomElement)1 ArrayList (java.util.ArrayList)1