org.springframework.data.elasticsearch.core.ReactiveIndexOperations Maven / Gradle / Ivy
/*
* Copyright 2020-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.elasticsearch.core;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Map;
import java.util.Set;
import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.index.*;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
/**
* Interface defining operations on indexes for the reactive stack.
*
* @author Peter-Josef Meisch
* @author George Popides
* @since 4.1
*/
public interface ReactiveIndexOperations {
// region index management
/**
* Create an index.
*
* @return a {@link Mono} signalling successful operation completion or an {@link Mono#error(Throwable) error} if eg.
* the index already exist.
*/
Mono create();
/**
* Create an index with the specified settings.
*
* @param settings index settings
* @return a {@link Mono} signalling successful operation completion or an {@link Mono#error(Throwable) error} if eg.
* the index already exist.
*/
Mono create(Map settings);
/**
* Create an index for given settings and mapping.
*
* @param settings the index settings
* @param mapping the index mapping
* @return a {@link Mono} signalling successful operation completion or an {@link Mono#error(Throwable) error} if eg.
* the index already exist.
* @since 4.2
*/
Mono create(Map settings, Document mapping);
/**
* Create an index with the settings and mapping defined for the entity this IndexOperations is bound to.
*
* @return a {@link Mono} signalling successful operation completion or an {@link Mono#error(Throwable) error} if eg.
* the index already exist.
* @since 4.2
*/
Mono createWithMapping();
/**
* Delete an index.
*
* @return a {@link Mono} signalling operation completion or an {@link Mono#error(Throwable) error}. If the index does
* not exist, a value of {@literal false is emitted}.
*/
Mono delete();
/**
* checks if an index exists
*
* @return a {@link Mono} with the result of exist check
*/
Mono exists();
/**
* Refresh the index(es) this IndexOperations is bound to
*
* @return a {@link Mono} signalling operation completion.
*/
Mono refresh();
// endregion
// region mappings
/**
* Creates the index mapping for the entity this IndexOperations is bound to.
*
* @return mapping object
*/
Mono createMapping();
/**
* Creates the index mapping for the given class
*
* @param clazz the clazz to create a mapping for
* @return a {@link Mono} with the mapping document
*/
Mono createMapping(Class clazz);
/**
* Writes the mapping to the index for the class this IndexOperations is bound to.
*
* @return {@literal true} if the mapping could be stored
*/
default Mono putMapping() {
return putMapping(createMapping());
}
/**
* writes a mapping to the index
*
* @param mapping the Document with the mapping definitions
* @return {@literal true} if the mapping could be stored
*/
Mono putMapping(Mono mapping);
/**
* Creates the index mapping for the given class and writes it to the index.
*
* @param clazz the clazz to create a mapping for
* @return {@literal true} if the mapping could be stored
*/
default Mono putMapping(Class clazz) {
return putMapping(createMapping(clazz));
}
/**
* Get mapping for the index targeted defined by this {@link ReactiveIndexOperations}
*
* @return the mapping
*/
Mono getMapping();
// endregion
// region settings
/**
* Creates the index settings for the entity this IndexOperations is bound to.
*
* @return a settings document.
* @since 4.1
*/
Mono createSettings();
/**
* Creates the index settings from the annotations on the given class
*
* @param clazz the class to create the index settings from
* @return a settings document.
* @since 4.1
*/
Mono createSettings(Class clazz);
/**
* get the settings for the index
*
* @return a {@link Mono} with a {@link Document} containing the index settings
*/
default Mono getSettings() {
return getSettings(false);
}
/**
* get the settings for the index
*
* @param includeDefaults whether or not to include all the default settings
* @return a {@link Mono} with a {@link Document} containing the index settings
*/
Mono getSettings(boolean includeDefaults);
// endregion
// region aliases
/**
* Executes the given {@link AliasActions}.
*
* @param aliasActions the actions to execute
* @return if the operation is acknowledged by Elasticsearch
* @since 4.1
*/
Mono alias(AliasActions aliasActions);
/**
* gets information about aliases
*
* @param aliasNames alias names, must not be {@literal null}
* @return a {@link Mono} of {@link Map} from index names to {@link AliasData} for that index
* @since 4.1
*/
Mono