Search in sources :

Example 1 with IndexSettings

use of com.enonic.xp.repository.IndexSettings in project xp by enonic.

the class CreateRepositoryHandler method setIndexDefinitions.

public void setIndexDefinitions(final ScriptValue data) {
    if (data != null) {
        final Map<String, Object> indexDefinitionsMap = data.getMap();
        final IndexDefinitions.Builder indexDefinitionsBuilder = IndexDefinitions.create();
        for (IndexType indexType : IndexType.values()) {
            final Map indexDefinitionMap = (Map) indexDefinitionsMap.get(indexType.getName());
            if (indexDefinitionMap != null) {
                final Map indexDefinitionSettingsMap = (Map) indexDefinitionMap.get("settings");
                IndexSettings indexSettings = indexDefinitionSettingsMap == null ? null : new IndexSettings(createJson(indexDefinitionSettingsMap));
                final Map indexDefinitionMappingMap = (Map) indexDefinitionMap.get("mapping");
                IndexMapping indexMapping = indexDefinitionMappingMap == null ? null : new IndexMapping(createJson(indexDefinitionMappingMap));
                final IndexDefinition indexDefinition = IndexDefinition.create().settings(indexSettings).mapping(indexMapping).build();
                indexDefinitionsBuilder.add(indexType, indexDefinition);
            }
        }
        this.indexDefinitions = indexDefinitionsBuilder.build();
    }
}
Also used : IndexMapping(com.enonic.xp.repository.IndexMapping) IndexDefinition(com.enonic.xp.repository.IndexDefinition) IndexSettings(com.enonic.xp.repository.IndexSettings) IndexType(com.enonic.xp.index.IndexType) Map(java.util.Map) IndexDefinitions(com.enonic.xp.repository.IndexDefinitions)

Example 2 with IndexSettings

use of com.enonic.xp.repository.IndexSettings in project xp by enonic.

the class StatusResource method createRepoReadOnlyJson.

private JsonNode createRepoReadOnlyJson() {
    final IndexSettings indexSettings = this.indexService.getIndexSettings(ContentConstants.CONTENT_REPO_ID, IndexType.SEARCH);
    final JsonNode writeJsonNode = indexSettings != null ? indexSettings.getNode().get("index.blocks.write") : null;
    return writeJsonNode != null ? writeJsonNode : JsonNodeFactory.instance.booleanNode(false);
}
Also used : IndexSettings(com.enonic.xp.repository.IndexSettings) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 3 with IndexSettings

use of com.enonic.xp.repository.IndexSettings in project xp by enonic.

the class IndexServiceImpl method doPurgeSearchIndex.

private void doPurgeSearchIndex(final RepositoryId repositoryId) {
    final String searchIndexName = IndexNameResolver.resolveSearchIndexName(repositoryId);
    indexServiceInternal.deleteIndices(searchIndexName);
    final IndexSettings indexSettings = getSearchIndexSettings(repositoryId);
    final IndexMapping indexMapping = getSearchIndexMapping(repositoryId);
    indexServiceInternal.createIndex(CreateIndexRequest.create().indexName(searchIndexName).indexSettings(indexSettings).mappings(Map.of(IndexType.SEARCH, indexMapping)).build());
    indexServiceInternal.waitForYellowStatus(searchIndexName);
}
Also used : IndexMapping(com.enonic.xp.repository.IndexMapping) IndexSettings(com.enonic.xp.repository.IndexSettings)

Example 4 with IndexSettings

use of com.enonic.xp.repository.IndexSettings in project xp by enonic.

the class NodeRepositoryServiceImpl method mergeWithDefaultSettings.

private IndexSettings mergeWithDefaultSettings(final CreateRepositoryParams params, final IndexType indexType) {
    final IndexSettings defaultSettings = getDefaultSettings(params.getRepositoryId(), indexType);
    final IndexSettings indexSettings = params.getRepositorySettings().getIndexSettings(indexType);
    if (indexSettings != null) {
        return new IndexSettings(JsonHelper.merge(defaultSettings.getNode(), indexSettings.getNode()));
    }
    return defaultSettings;
}
Also used : IndexSettings(com.enonic.xp.repository.IndexSettings)

Example 5 with IndexSettings

use of com.enonic.xp.repository.IndexSettings in project xp by enonic.

the class NodeRepositoryServiceImpl method createIndex.

private void createIndex(final CreateRepositoryParams params, final IndexType indexType, final Map<IndexType, IndexMapping> mappings) {
    final RepositoryId repositoryId = params.getRepositoryId();
    final IndexSettings mergedSettings = mergeWithDefaultSettings(params, indexType);
    indexServiceInternal.createIndex(CreateIndexRequest.create().indexName(resolveIndexName(repositoryId, indexType)).mappings(mappings).indexSettings(mergedSettings).build());
}
Also used : IndexSettings(com.enonic.xp.repository.IndexSettings) RepositoryId(com.enonic.xp.repository.RepositoryId)

Aggregations

IndexSettings (com.enonic.xp.repository.IndexSettings)11 IndexMapping (com.enonic.xp.repository.IndexMapping)4 IndexType (com.enonic.xp.index.IndexType)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)2 IndexDefinition (com.enonic.xp.repository.IndexDefinition)2 Map (java.util.Map)2 Test (org.junit.jupiter.api.Test)2 PropertySet (com.enonic.xp.data.PropertySet)1 UpdateIndexSettings (com.enonic.xp.repo.impl.index.UpdateIndexSettings)1 IndexDefinitions (com.enonic.xp.repository.IndexDefinitions)1 IndexException (com.enonic.xp.repository.IndexException)1 Repository (com.enonic.xp.repository.Repository)1 RepositoryId (com.enonic.xp.repository.RepositoryId)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)1 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)1 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)1