Search in sources :

Example 1 with FieldConfig

use of io.zulia.message.ZuliaIndex.FieldConfig in project zuliasearch by zuliaio.

the class FieldConfigMapper method getFieldConfigs.

public List<FieldConfig> getFieldConfigs() {
    List<FieldConfig> configs = new ArrayList<>();
    for (String fieldName : fieldConfigMap.keySet()) {
        FieldConfig fieldConfig = fieldConfigMap.get(fieldName);
        configs.add(fieldConfig);
    }
    for (FieldConfigMapper fcm : embeddedFieldConfigMappers) {
        configs.addAll(fcm.getFieldConfigs());
    }
    LOG.info(configs.toString());
    return configs;
}
Also used : FieldConfig(io.zulia.message.ZuliaIndex.FieldConfig) ArrayList(java.util.ArrayList)

Example 2 with FieldConfig

use of io.zulia.message.ZuliaIndex.FieldConfig in project zuliasearch by zuliaio.

the class ServerIndexConfig method configure.

public void configure(IndexSettings indexSettings) {
    this.indexSettings = indexSettings;
    this.analyzerMap = new ConcurrentHashMap<>();
    analyzerMap.put(DefaultAnalyzers.STANDARD, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.STOPWORDS).build());
    analyzerMap.put(DefaultAnalyzers.KEYWORD, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.KEYWORD).setTokenizer(Tokenizer.KEYWORD).build());
    analyzerMap.put(DefaultAnalyzers.LC_KEYWORD, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.LC_KEYWORD).setTokenizer(Tokenizer.KEYWORD).addFilter(Filter.LOWERCASE).build());
    analyzerMap.put(DefaultAnalyzers.MIN_STEM, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.MIN_STEM).setTokenizer(Tokenizer.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.STOPWORDS).addFilter(Filter.ENGLISH_MIN_STEM).build());
    analyzerMap.put(DefaultAnalyzers.TWO_TWO_SHINGLE, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.TWO_TWO_SHINGLE).setTokenizer(Tokenizer.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.TWO_TWO_SHINGLE).build());
    analyzerMap.put(DefaultAnalyzers.THREE_THREE_SHINGLE, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.THREE_THREE_SHINGLE).setTokenizer(Tokenizer.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.THREE_THREE_SHINGLE).build());
    analyzerMap.put(DefaultAnalyzers.LC_CONCAT_ALL, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.LC_CONCAT_ALL).setTokenizer(Tokenizer.KEYWORD).addFilter(Filter.LOWERCASE).addFilter(Filter.CONCAT_ALL).build());
    analyzerMap.put(DefaultAnalyzers.KSTEMMED, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.KSTEMMED).setTokenizer(Tokenizer.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.STOPWORDS).addFilter(Filter.KSTEM).build());
    analyzerMap.put(DefaultAnalyzers.LSH, AnalyzerSettings.newBuilder().setName(DefaultAnalyzers.LSH).setTokenizer(Tokenizer.STANDARD).addFilter(Filter.LOWERCASE).addFilter(Filter.ASCII_FOLDING).addFilter(Filter.KSTEM).addFilter(Filter.STOPWORDS).addFilter(Filter.FIVE_FIVE_SHINGLE).addFilter(Filter.MINHASH).build());
    for (AnalyzerSettings analyzerSettings : indexSettings.getAnalyzerSettingsList()) {
        analyzerMap.put(analyzerSettings.getName(), analyzerSettings);
    }
    this.fieldConfigMap = new ConcurrentHashMap<>();
    for (FieldConfig fc : indexSettings.getFieldConfigList()) {
        fieldConfigMap.put(fc.getStoredFieldName(), fc);
    }
    this.indexAsMap = new ConcurrentHashMap<>();
    this.indexToStoredMap = new ConcurrentHashMap<>();
    for (String storedFieldName : fieldConfigMap.keySet()) {
        FieldConfig fc = fieldConfigMap.get(storedFieldName);
        for (IndexAs indexAs : fc.getIndexAsList()) {
            indexAsMap.put(indexAs.getIndexFieldName(), indexAs);
            indexToStoredMap.put(indexAs.getIndexFieldName(), storedFieldName);
        }
    }
    this.facetAsMap = new ConcurrentHashMap<>();
    for (String storedFieldName : fieldConfigMap.keySet()) {
        FieldConfig fc = fieldConfigMap.get(storedFieldName);
        for (FacetAs facetAs : fc.getFacetAsList()) {
            facetAsMap.put(facetAs.getFacetName(), facetAs);
        }
    }
    this.indexFieldType = new ConcurrentHashMap<>();
    for (String storedFieldName : fieldConfigMap.keySet()) {
        FieldConfig fc = fieldConfigMap.get(storedFieldName);
        for (IndexAs indexAs : fc.getIndexAsList()) {
            indexFieldType.put(indexAs.getIndexFieldName(), fc.getFieldType());
        }
    }
    this.sortFieldType = new ConcurrentHashMap<>();
    for (String storedFieldName : fieldConfigMap.keySet()) {
        FieldConfig fc = fieldConfigMap.get(storedFieldName);
        for (SortAs sortAs : fc.getSortAsList()) {
            sortFieldType.put(sortAs.getSortFieldName(), fc.getFieldType());
        }
    }
    this.superbitConfigMap = new ConcurrentHashMap<>();
    this.superbitMap = new ConcurrentHashMap<>();
    for (String storedFieldName : fieldConfigMap.keySet()) {
        FieldConfig fc = fieldConfigMap.get(storedFieldName);
        for (ProjectAs projectAs : fc.getProjectAsList()) {
            String field = projectAs.getField();
            if (projectAs.hasSuperbit()) {
                Superbit superbit = projectAs.getSuperbit();
                superbitConfigMap.put(field, superbit);
                SuperBit superBit = new SuperBit(superbit.getInputDim(), superbit.getInputDim(), superbit.getBatches(), superbit.getSeed());
                superbitMap.put(field, superBit);
            }
        }
    }
}
Also used : SortAs(io.zulia.message.ZuliaIndex.SortAs) FacetAs(io.zulia.message.ZuliaIndex.FacetAs) FieldConfig(io.zulia.message.ZuliaIndex.FieldConfig) ProjectAs(io.zulia.message.ZuliaIndex.ProjectAs) IndexAs(io.zulia.message.ZuliaIndex.IndexAs) AnalyzerSettings(io.zulia.message.ZuliaIndex.AnalyzerSettings) Superbit(io.zulia.message.ZuliaIndex.Superbit) SuperBit(info.debatty.java.lsh.SuperBit)

Example 3 with FieldConfig

use of io.zulia.message.ZuliaIndex.FieldConfig in project zuliasearch by zuliaio.

the class ClientIndexConfig method configure.

public void configure(IndexSettings indexSettings) {
    this.indexName = indexSettings.getIndexName();
    this.numberOfShards = indexSettings.getNumberOfShards();
    this.numberOfReplicas = indexSettings.getNumberOfReplicas();
    this.defaultSearchFields = indexSettings.getDefaultSearchFieldList();
    this.analyzerSettingsMap = new TreeMap<>();
    for (AnalyzerSettings analyzerSettings : indexSettings.getAnalyzerSettingsList()) {
        analyzerSettingsMap.put(analyzerSettings.getName(), analyzerSettings);
    }
    this.fieldMap = new TreeMap<>();
    for (FieldConfig fc : indexSettings.getFieldConfigList()) {
        fieldMap.put(fc.getStoredFieldName(), fc);
    }
    this.requestFactor = indexSettings.getRequestFactor();
    this.minShardRequest = indexSettings.getMinShardRequest();
    this.shardTolerance = indexSettings.getShardTolerance();
    this.shardQueryCacheSize = indexSettings.getShardQueryCacheSize();
    this.shardQueryCacheMaxAmount = indexSettings.getShardQueryCacheMaxAmount();
    this.idleTimeWithoutCommit = indexSettings.getIdleTimeWithoutCommit();
    this.shardCommitInterval = indexSettings.getShardCommitInterval();
    this.indexWeight = indexSettings.getIndexWeight();
    this.ramBufferMB = indexSettings.getRamBufferMB();
}
Also used : FieldConfig(io.zulia.message.ZuliaIndex.FieldConfig) AnalyzerSettings(io.zulia.message.ZuliaIndex.AnalyzerSettings)

Example 4 with FieldConfig

use of io.zulia.message.ZuliaIndex.FieldConfig in project zuliasearch by zuliaio.

the class ClientIndexConfig method getIndexSettings.

public IndexSettings getIndexSettings() {
    IndexSettings.Builder isb = IndexSettings.newBuilder();
    if (numberOfShards != null) {
        isb.setNumberOfShards(numberOfShards);
    }
    if (indexName != null) {
        isb.setIndexName(indexName);
    }
    if (defaultSearchFields != null) {
        isb.addAllDefaultSearchField(defaultSearchFields);
    }
    if (requestFactor != null) {
        isb.setRequestFactor(requestFactor);
    }
    if (minShardRequest != null) {
        isb.setMinShardRequest(minShardRequest);
    }
    if (shardCommitInterval != null) {
        isb.setShardCommitInterval(shardCommitInterval);
    }
    if (idleTimeWithoutCommit != null) {
        isb.setIdleTimeWithoutCommit(idleTimeWithoutCommit);
    }
    if (shardTolerance != null) {
        isb.setShardTolerance(shardTolerance);
    }
    if (indexWeight != null) {
        isb.setIndexWeight(indexWeight);
    }
    if (ramBufferMB != null) {
        isb.setRamBufferMB(ramBufferMB);
    }
    for (String fieldName : fieldMap.keySet()) {
        FieldConfig fieldConfig = fieldMap.get(fieldName);
        isb.addFieldConfig(fieldConfig);
    }
    for (String analyzerName : analyzerSettingsMap.keySet()) {
        isb.addAnalyzerSettings(analyzerSettingsMap.get(analyzerName));
    }
    return isb.build();
}
Also used : FieldConfig(io.zulia.message.ZuliaIndex.FieldConfig) IndexSettings(io.zulia.message.ZuliaIndex.IndexSettings)

Example 5 with FieldConfig

use of io.zulia.message.ZuliaIndex.FieldConfig 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)

Aggregations

FieldConfig (io.zulia.message.ZuliaIndex.FieldConfig)5 AnalyzerSettings (io.zulia.message.ZuliaIndex.AnalyzerSettings)2 SuperBit (info.debatty.java.lsh.SuperBit)1 CreateIndex (io.zulia.client.command.CreateIndex)1 ClientIndexConfig (io.zulia.client.config.ClientIndexConfig)1 FacetAs (io.zulia.message.ZuliaIndex.FacetAs)1 IndexAs (io.zulia.message.ZuliaIndex.IndexAs)1 IndexSettings (io.zulia.message.ZuliaIndex.IndexSettings)1 ProjectAs (io.zulia.message.ZuliaIndex.ProjectAs)1 SortAs (io.zulia.message.ZuliaIndex.SortAs)1 Superbit (io.zulia.message.ZuliaIndex.Superbit)1 ArrayList (java.util.ArrayList)1