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