Search in sources :

Example 1 with CreateIndex

use of io.zulia.client.command.CreateIndex in project zuliasearch by zuliaio.

the class Mapper method createOrUpdateIndex.

public CreateIndex createOrUpdateIndex() {
    if (settings == null) {
        throw new RuntimeException("No Settings annotation for class <" + clazz.getSimpleName() + ">");
    }
    ClientIndexConfig indexConfig = new ClientIndexConfig();
    for (DefaultSearchFieldInfo<T> defaultSearchField : defaultSearchFields) {
        indexConfig.addDefaultSearchField(defaultSearchField.getFieldName());
    }
    indexConfig.setIndexName(settings.indexName());
    indexConfig.setNumberOfShards(settings.numberOfShards());
    indexConfig.setRequestFactor(settings.requestFactor());
    indexConfig.setMinShardRequest(settings.minSeqmentRequest());
    indexConfig.setIdleTimeWithoutCommit(settings.idleTimeWithoutCommit());
    indexConfig.setShardCommitInterval(settings.shardCommitInterval());
    indexConfig.setShardTolerance(settings.shardTolerance());
    indexConfig.setShardQueryCacheSize(settings.shardQueryCacheSize());
    indexConfig.setShardQueryCacheMaxAmount(settings.shardQueryCacheMaxAmount());
    for (FieldConfig fieldConfig : fieldConfigMapper.getFieldConfigs()) {
        indexConfig.addFieldConfig(fieldConfig);
    }
    return new CreateIndex(indexConfig);
}
Also used : CreateIndex(io.zulia.client.command.CreateIndex) FieldConfig(io.zulia.message.ZuliaIndex.FieldConfig) ClientIndexConfig(io.zulia.client.config.ClientIndexConfig)

Example 2 with CreateIndex

use of io.zulia.client.command.CreateIndex in project zuliasearch by zuliaio.

the class FileStorageTest method createIndex.

private void createIndex() throws Exception {
    ClientIndexConfig indexConfig = new ClientIndexConfig();
    indexConfig.setIndexName(TEST_INDEX);
    indexConfig.setNumberOfShards(1);
    indexConfig.setShardCommitInterval(64000);
    indexConfig.addAnalyzerSetting(ZuliaIndex.AnalyzerSettings.newBuilder().setName("text").addFilter(ZuliaIndex.AnalyzerSettings.Filter.CASE_PROTECTED_WORDS).addFilter(ZuliaIndex.AnalyzerSettings.Filter.LOWERCASE).addFilter(ZuliaIndex.AnalyzerSettings.Filter.ASCII_FOLDING).addFilter(ZuliaIndex.AnalyzerSettings.Filter.ENGLISH_POSSESSIVE).addFilter(ZuliaIndex.AnalyzerSettings.Filter.ENGLISH_MIN_STEM).addFilter(ZuliaIndex.AnalyzerSettings.Filter.BRITISH_US).build());
    indexConfig.addAnalyzerSetting(ZuliaIndex.AnalyzerSettings.newBuilder().setName("entity").addFilter(ZuliaIndex.AnalyzerSettings.Filter.LOWERCASE).addFilter(ZuliaIndex.AnalyzerSettings.Filter.ASCII_FOLDING).build());
    FieldConfigBuilder fieldConfigBuilder = FieldConfigBuilder.create("title", ZuliaIndex.FieldConfig.FieldType.STRING);
    fieldConfigBuilder.indexAs("text", "title");
    fieldConfigBuilder.displayName("Title");
    indexConfig.addFieldConfig(fieldConfigBuilder);
    FieldConfigBuilder fieldConfigBuilder2 = FieldConfigBuilder.create("abstract", ZuliaIndex.FieldConfig.FieldType.STRING);
    fieldConfigBuilder2.indexAs("text", "abstract");
    fieldConfigBuilder2.displayName("Abstract");
    indexConfig.addFieldConfig(fieldConfigBuilder2);
    FieldConfigBuilder fieldConfigBuilder3 = FieldConfigBuilder.create("id", ZuliaIndex.FieldConfig.FieldType.STRING);
    fieldConfigBuilder3.indexAs(DefaultAnalyzers.STANDARD, "id");
    fieldConfigBuilder3.displayName("ID");
    indexConfig.addFieldConfig(fieldConfigBuilder3);
    CreateIndex createOrUpdateIndex = new CreateIndex(indexConfig);
    zuliaWorkPool.createIndex(createOrUpdateIndex);
}
Also used : CreateIndex(io.zulia.client.command.CreateIndex) ClientIndexConfig(io.zulia.client.config.ClientIndexConfig) FieldConfigBuilder(io.zulia.fields.FieldConfigBuilder)

Aggregations

CreateIndex (io.zulia.client.command.CreateIndex)2 ClientIndexConfig (io.zulia.client.config.ClientIndexConfig)2 FieldConfigBuilder (io.zulia.fields.FieldConfigBuilder)1 FieldConfig (io.zulia.message.ZuliaIndex.FieldConfig)1