code
stringlengths 25
201k
| docstring
stringlengths 19
96.2k
| func_name
stringlengths 0
235
| language
stringclasses 1
value | repo
stringlengths 8
51
| path
stringlengths 11
314
| url
stringlengths 62
377
| license
stringclasses 7
values |
|---|---|---|---|---|---|---|---|
@Override
public void process(HttpRequest request, HttpContext context) {
HttpHeaders httpHeaders = headersSupplier.get();
if (httpHeaders != null && !httpHeaders.isEmpty()) {
Arrays.stream(toHeaderArray(httpHeaders)).forEach(request::addHeader);
}
}
|
Interceptor to inject custom supplied headers.
@since 4.4
|
process
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
Apache-2.0
|
static ElasticsearchHttpClientConfigurationCallback from(
Function<HttpAsyncClientBuilder, HttpAsyncClientBuilder> httpClientBuilderCallback) {
Assert.notNull(httpClientBuilderCallback, "httpClientBuilderCallback must not be null");
return httpClientBuilderCallback::apply;
}
|
{@link org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationCallback} to configure
the Elasticsearch RestClient's Http client with a {@link HttpAsyncClientBuilder}
@since 4.4
|
from
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
Apache-2.0
|
static ElasticsearchRestClientConfigurationCallback from(
Function<RestClientBuilder, RestClientBuilder> restClientBuilderCallback) {
Assert.notNull(restClientBuilderCallback, "restClientBuilderCallback must not be null");
return restClientBuilderCallback::apply;
}
|
{@link org.springframework.data.elasticsearch.client.ClientConfiguration.ClientConfigurationCallback} to configure
the RestClient client with a {@link RestClientBuilder}
@since 5.0
|
from
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
|
Apache-2.0
|
@Bean
public RestClient elasticsearchRestClient(ClientConfiguration clientConfiguration) {
Assert.notNull(clientConfiguration, "clientConfiguration must not be null");
return ElasticsearchClients.getRestClient(clientConfiguration);
}
|
Provides the underlying low level Elasticsearch RestClient.
@param clientConfiguration configuration for the client, must not be {@literal null}
@return RestClient
|
elasticsearchRestClient
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
Apache-2.0
|
@Bean
public ElasticsearchClient elasticsearchClient(ElasticsearchTransport transport) {
Assert.notNull(transport, "transport must not be null");
return ElasticsearchClients.createImperative(transport);
}
|
Provides the {@link ElasticsearchClient} to be used.
@param transport the {@link ElasticsearchTransport} to use
@return ElasticsearchClient instance
|
elasticsearchClient
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
Apache-2.0
|
@Bean(name = { "elasticsearchOperations", "elasticsearchTemplate" })
public ElasticsearchOperations elasticsearchOperations(ElasticsearchConverter elasticsearchConverter,
ElasticsearchClient elasticsearchClient) {
ElasticsearchTemplate template = new ElasticsearchTemplate(elasticsearchClient, elasticsearchConverter);
template.setRefreshPolicy(refreshPolicy());
return template;
}
|
Creates a {@link ElasticsearchOperations} implementation using an
{@link co.elastic.clients.elasticsearch.ElasticsearchClient}.
@return never {@literal null}.
|
elasticsearchOperations
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
Apache-2.0
|
@Bean
public JsonpMapper jsonpMapper() {
// we need to create our own objectMapper that keeps null values in order to provide the storeNullValue
// functionality. The one Elasticsearch would provide removes the nulls. We remove unwanted nulls before they get
// into this mapper, so we can safely keep them here.
var objectMapper = (new ObjectMapper())
.configure(SerializationFeature.INDENT_OUTPUT, false)
.setSerializationInclusion(JsonInclude.Include.ALWAYS);
return new JacksonJsonpMapper(objectMapper);
}
|
Provides the JsonpMapper bean that is used in the {@link #elasticsearchTransport(RestClient, JsonpMapper)} method.
@return the {@link JsonpMapper} to use
@since 5.2
|
jsonpMapper
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchConfiguration.java
|
Apache-2.0
|
@SuppressWarnings({ "unchecked", "rawtypes" })
private List<SearchHits<?>> getSearchHitsFromMsearchResponse(int size, List<Class<?>> classes,
List<IndexCoordinates> indices, List<MultiSearchResponseItem<EntityAsMap>> responseItems) {
List<SearchHits<?>> searchHitsList = new ArrayList<>(size);
Iterator<Class<?>> clazzIter = classes.iterator();
Iterator<IndexCoordinates> indexIter = indices.iterator();
Iterator<MultiSearchResponseItem<EntityAsMap>> responseIterator = responseItems.iterator();
while (clazzIter.hasNext() && indexIter.hasNext()) {
MultiSearchResponseItem<EntityAsMap> responseItem = responseIterator.next();
if (responseItem.isResult()) {
Class clazz = clazzIter.next();
IndexCoordinates index = indexIter.next();
ReadDocumentCallback<?> documentCallback = new ReadDocumentCallback<>(elasticsearchConverter, clazz,
index);
SearchDocumentResponseCallback<SearchHits<?>> callback = new ReadSearchDocumentResponseCallback<>(clazz,
index);
SearchHits<?> searchHits = callback.doWith(
SearchDocumentResponseBuilder.from(responseItem.result(), getEntityCreator(documentCallback), jsonpMapper));
searchHitsList.add(searchHits);
} else {
if (LOGGER.isWarnEnabled()) {
LOGGER.warn(String.format("multisearch response contains failure: %s",
responseItem.failure().error().reason()));
}
}
}
return searchHitsList;
}
|
{@link MsearchResponse} and {@link MsearchTemplateResponse} share the same {@link MultiSearchResponseItem}
|
getSearchHitsFromMsearchResponse
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchTemplate.java
|
Apache-2.0
|
protected List<IndexedObjectInformation> checkForBulkOperationFailure(BulkResponse bulkResponse) {
if (bulkResponse.errors()) {
Map<String, BulkFailureException.FailureDetails> failedDocuments = new HashMap<>();
for (BulkResponseItem item : bulkResponse.items()) {
if (item.error() != null) {
failedDocuments.put(item.id(), new BulkFailureException.FailureDetails(item.status(), item.error().reason()));
}
}
throw new BulkFailureException(
"Bulk operation has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages ["
+ failedDocuments + ']',
failedDocuments);
}
return bulkResponse.items().stream().map(
item -> new IndexedObjectInformation(item.id(), item.index(), item.seqNo(), item.primaryTerm(), item.version()))
.collect(Collectors.toList());
}
|
extract the list of {@link IndexedObjectInformation} from a {@link BulkResponse}.
@param bulkResponse the response to evaluate
@return the list of the {@link IndexedObjectInformation}s
|
checkForBulkOperationFailure
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchTemplate.java
|
Apache-2.0
|
public void setSpringDataQuery(org.springframework.data.elasticsearch.core.query.@Nullable Query springDataQuery) {
this.springDataQuery = springDataQuery;
}
|
@see NativeQueryBuilder#withQuery(org.springframework.data.elasticsearch.core.query.Query).
@since 5.1
|
setSpringDataQuery
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/NativeQuery.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/NativeQuery.java
|
Apache-2.0
|
public NativeQueryBuilder withQuery(org.springframework.data.elasticsearch.core.query.Query query) {
this.springDataQuery = query;
return this;
}
|
Allows to use a {@link org.springframework.data.elasticsearch.core.query.Query} within a NativeQuery. Cannot be
used together with {@link #withQuery(Query)} that sets an Elasticsearch query. Passing in a {@link NativeQuery}
will result in an exception when {@link #build()} is called.
@since 5.1
|
withQuery
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/NativeQueryBuilder.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/NativeQueryBuilder.java
|
Apache-2.0
|
@Bean
public ReactiveElasticsearchClient reactiveElasticsearchClient(ElasticsearchTransport transport) {
Assert.notNull(transport, "transport must not be null");
return ElasticsearchClients.createReactive(transport);
}
|
Provides the {@link ReactiveElasticsearchClient} instance used.
@param transport the ElasticsearchTransport to use
@return ReactiveElasticsearchClient instance.
|
reactiveElasticsearchClient
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
Apache-2.0
|
@Bean(name = { "reactiveElasticsearchOperations", "reactiveElasticsearchTemplate" })
public ReactiveElasticsearchOperations reactiveElasticsearchOperations(ElasticsearchConverter elasticsearchConverter,
ReactiveElasticsearchClient reactiveElasticsearchClient) {
ReactiveElasticsearchTemplate template = new ReactiveElasticsearchTemplate(reactiveElasticsearchClient,
elasticsearchConverter);
template.setRefreshPolicy(refreshPolicy());
return template;
}
|
Creates {@link ReactiveElasticsearchOperations}.
@return never {@literal null}.
|
reactiveElasticsearchOperations
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
Apache-2.0
|
@Bean
public JsonpMapper jsonpMapper() {
return new JacksonJsonpMapper();
}
|
Provides the JsonpMapper that is used in the {@link #elasticsearchTransport(RestClient, JsonpMapper)} method and
exposes it as a bean.
@return the {@link JsonpMapper} to use
@since 5.2
|
jsonpMapper
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchConfiguration.java
|
Apache-2.0
|
@Override
public ReactiveElasticsearchSqlClient withTransportOptions(@Nullable TransportOptions transportOptions) {
return new ReactiveElasticsearchSqlClient(transport, transportOptions);
}
|
Reactive version of {@link co.elastic.clients.elasticsearch.sql.ElasticsearchSqlClient}.
@author Aouichaoui Youssef
@since 5.4
|
withTransportOptions
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchSqlClient.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchSqlClient.java
|
Apache-2.0
|
public final Mono<QueryResponse> query(Function<QueryRequest.Builder, ObjectBuilder<QueryRequest>> fn)
throws IOException, ElasticsearchException {
return query(fn.apply(new QueryRequest.Builder()).build());
}
|
Executes a SQL request
@param fn a function that initializes a builder to create the {@link QueryRequest}.
|
query
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchSqlClient.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchSqlClient.java
|
Apache-2.0
|
public <T> Publisher<T> execute(ReactiveElasticsearchTemplate.ClientCallback<Publisher<T>> callback) {
return Flux.defer(() -> callback.doWithClient(client)).onErrorMap(this::translateException);
}
|
Execute a callback with the {@link ReactiveElasticsearchClient} and provide exception translation.
@param callback the callback to execute, must not be {@literal null}
@param <T> the type returned from the callback
@return the callback result
|
execute
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ReactiveElasticsearchTemplate.java
|
Apache-2.0
|
public static <T> SearchDocumentResponse from(ResponseBody<EntityAsMap> responseBody,
SearchDocumentResponse.EntityCreator<T> entityCreator, JsonpMapper jsonpMapper) {
Assert.notNull(responseBody, "responseBody must not be null");
Assert.notNull(entityCreator, "entityCreator must not be null");
Assert.notNull(jsonpMapper, "jsonpMapper must not be null");
HitsMetadata<EntityAsMap> hitsMetadata = responseBody.hits();
String scrollId = responseBody.scrollId();
Map<String, Aggregate> aggregations = responseBody.aggregations();
Map<String, List<Suggestion<EntityAsMap>>> suggest = responseBody.suggest();
var pointInTimeId = responseBody.pitId();
var shards = responseBody.shards();
var executionDurationInMillis = responseBody.took();
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest,
entityCreator, jsonpMapper);
}
|
creates a SearchDocumentResponse from the {@link SearchResponse}
@param responseBody the Elasticsearch response body
@param entityCreator function to create an entity from a {@link SearchDocument}
@param jsonpMapper to map JsonData objects
@return the SearchDocumentResponse
|
from
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilder.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilder.java
|
Apache-2.0
|
public static <T> SearchDocumentResponse from(SearchTemplateResponse<EntityAsMap> response,
SearchDocumentResponse.EntityCreator<T> entityCreator, JsonpMapper jsonpMapper) {
Assert.notNull(response, "response must not be null");
Assert.notNull(entityCreator, "entityCreator must not be null");
Assert.notNull(jsonpMapper, "jsonpMapper must not be null");
var shards = response.shards();
var hitsMetadata = response.hits();
var scrollId = response.scrollId();
var aggregations = response.aggregations();
var suggest = response.suggest();
var pointInTimeId = response.pitId();
var executionDurationInMillis = response.took();
return from(hitsMetadata, shards, scrollId, pointInTimeId, executionDurationInMillis, aggregations, suggest,
entityCreator, jsonpMapper);
}
|
creates a SearchDocumentResponse from the {@link SearchTemplateResponse}
@param response the Elasticsearch response body
@param entityCreator function to create an entity from a {@link SearchDocument}
@param jsonpMapper to map JsonData objects
@return the SearchDocumentResponse
@since 5.1
|
from
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilder.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/SearchDocumentResponseBuilder.java
|
Apache-2.0
|
@Nullable
static Float toFloat(@Nullable Long value) {
return value != null ? Float.valueOf(value) : null;
}
|
Converts a Long to a Float, returning null if the input is null.
@param value the long value
@return a FLoat with the given value
@since 5.0
|
toFloat
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
Apache-2.0
|
@Nullable
static Operator operator(@Nullable OperatorType operator) {
return operator != null ? Operator.valueOf(operator.name()) : null;
}
|
Convert a spring-data-elasticsearch operator to an Elasticsearch operator.
@param operator spring-data-elasticsearch operator.
@return an Elasticsearch Operator.
@since 5.3
|
operator
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
Apache-2.0
|
@Nullable
static Conflicts conflicts(@Nullable ConflictsType conflicts) {
return conflicts != null ? Conflicts.valueOf(conflicts.name()) : null;
}
|
Convert a spring-data-elasticsearch {@literal conflicts} to an Elasticsearch {@literal conflicts}.
@param conflicts spring-data-elasticsearch {@literal conflicts}.
@return an Elasticsearch {@literal conflicts}.
@since 5.3
|
conflicts
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
Apache-2.0
|
static ChildScoreMode scoreMode(HasChildQuery.@Nullable ScoreMode scoreMode) {
if (scoreMode == null) {
return ChildScoreMode.None;
}
return switch (scoreMode) {
case Avg -> ChildScoreMode.Avg;
case Max -> ChildScoreMode.Max;
case Min -> ChildScoreMode.Min;
case Sum -> ChildScoreMode.Sum;
default -> ChildScoreMode.None;
};
}
|
Convert a spring-data-elasticsearch {@literal scoreMode} to an Elasticsearch {@literal scoreMode}.
@param scoreMode spring-data-elasticsearch {@literal scoreMode}.
@return an Elasticsearch {@literal scoreMode}.
|
scoreMode
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/TypeUtils.java
|
Apache-2.0
|
@Override
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
hints.reflection()
.registerType(TypeReference.of(IndexSettings.class), builder -> builder.withField("_DESERIALIZER")) //
.registerType(TypeReference.of(PutMappingRequest.class), builder -> builder.withField("_DESERIALIZER")) //
.registerType(TypeReference.of(RuntimeFieldType.class), builder -> builder.withField("_DESERIALIZER"))//
.registerType(TypeReference.of(TypeMapping.class), builder -> builder.withField("_DESERIALIZER")) //
;
hints.serialization() //
.registerType(org.apache.http.impl.auth.BasicScheme.class) //
.registerType(org.apache.http.impl.auth.RFC2617Scheme.class) //
.registerType(java.util.HashMap.class) //
;
hints.resources() //
.registerPattern("co/elastic/clients/version.properties") //
;
}
|
runtime hints for the Elasticsearch client libraries, as these do not provide any of their own.
@author Peter-Josef Meisch
@since 5.1
|
registerHints
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/client/elc/aot/ElasticsearchClientRuntimeHints.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/aot/ElasticsearchClientRuntimeHints.java
|
Apache-2.0
|
@Bean
public SimpleElasticsearchMappingContext elasticsearchMappingContext(
ElasticsearchCustomConversions elasticsearchCustomConversions) {
SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(getInitialEntitySet());
mappingContext.setSimpleTypeHolder(elasticsearchCustomConversions.getSimpleTypeHolder());
mappingContext.setFieldNamingStrategy(fieldNamingStrategy());
mappingContext.setWriteTypeHints(writeTypeHints());
return mappingContext;
}
|
Creates a {@link SimpleElasticsearchMappingContext} equipped with entity classes scanned from the mapping base
package.
@see #getMappingBasePackages()
@return never {@literal null}.
|
elasticsearchMappingContext
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
@Bean
public ElasticsearchCustomConversions elasticsearchCustomConversions() {
return new ElasticsearchCustomConversions(Collections.emptyList());
}
|
Register custom {@link Converter}s in a {@link ElasticsearchCustomConversions} object if required.
@return never {@literal null}.
|
elasticsearchCustomConversions
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
protected Collection<String> getMappingBasePackages() {
Package mappingBasePackage = getClass().getPackage();
return Collections.singleton(mappingBasePackage == null ? null : mappingBasePackage.getName());
}
|
Returns the base packages to scan for Elasticsearch mapped entities at startup. Will return the package name of the
configuration class' (the concrete class, not this one here) by default. So if you have a
{@code com.acme.AppConfig} extending {@link ElasticsearchConfigurationSupport} the base package will be considered
{@code com.acme} unless the method is overridden to implement alternate behavior.
@return the base packages to scan for mapped {@link Document} classes or an empty collection to not enable scanning
for entities.
|
getMappingBasePackages
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
protected Set<Class<?>> getInitialEntitySet() {
Set<Class<?>> initialEntitySet = new HashSet<>();
for (String basePackage : getMappingBasePackages()) {
initialEntitySet.addAll(scanForEntities(basePackage));
}
return initialEntitySet;
}
|
Scans the mapping base package for classes annotated with {@link Document}. By default, it scans for entities in
all packages returned by {@link #getMappingBasePackages()}.
@see #getMappingBasePackages()
@return never {@literal null}.
|
getInitialEntitySet
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
protected Set<Class<?>> scanForEntities(String basePackage) {
if (!StringUtils.hasText(basePackage)) {
return Collections.emptySet();
}
Set<Class<?>> initialEntitySet = new HashSet<>();
ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider(
false);
componentProvider.addIncludeFilter(new AnnotationTypeFilter(Document.class));
for (BeanDefinition candidate : componentProvider.findCandidateComponents(basePackage)) {
String beanClassName = candidate.getBeanClassName();
if (beanClassName != null) {
try {
initialEntitySet
.add(ClassUtils.forName(beanClassName, ElasticsearchConfigurationSupport.class.getClassLoader()));
} catch (ClassNotFoundException | LinkageError ignored) {}
}
}
return initialEntitySet;
}
|
Scans the given base package for entities, i.e. Elasticsearch specific types annotated with {@link Document}.
@param basePackage must not be {@literal null}.
@return never {@literal null}.
|
scanForEntities
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
@Nullable
protected RefreshPolicy refreshPolicy() {
return null;
}
|
Set up the write {@link RefreshPolicy}. Default is set to null to use the cluster defaults..
@return {@literal null} to use the server defaults.
|
refreshPolicy
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
protected FieldNamingStrategy fieldNamingStrategy() {
return PropertyNameFieldNamingStrategy.INSTANCE;
}
|
Configures a {@link FieldNamingStrategy} on the {@link SimpleElasticsearchMappingContext} instance created.
@return the {@link FieldNamingStrategy} to use
@since 4.2
|
fieldNamingStrategy
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
protected boolean writeTypeHints() {
return true;
}
|
Flag specifiying if type hints (_class fields) should be written in the index. It is strongly advised to keep the
default value of {@literal true}. If you need to write to an existing index that does not have a mapping defined
for these fields and that has a strict mapping set, then it might be necessary to disable type hints. But notice
that in this case reading polymorphic types may fail.
@return flag if type hints should be written
@since 4.3
|
writeTypeHints
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchConfigurationSupport.java
|
Apache-2.0
|
@Override
public void init() {
RepositoryConfigurationExtension extension = new ElasticsearchRepositoryConfigExtension();
RepositoryBeanDefinitionParser parser = new RepositoryBeanDefinitionParser(extension);
registerBeanDefinitionParser("repositories", parser);
registerBeanDefinitionParser("elasticsearch-client", new ElasticsearchClientBeanDefinitionParser());
}
|
ElasticsearchNamespaceHandler
@author Rizwan Idrees
@author Mohsin Husen
@author Don Wellington
|
init
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchNamespaceHandler.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/config/ElasticsearchNamespaceHandler.java
|
Apache-2.0
|
@Override
public ElasticsearchConverter getElasticsearchConverter() {
return converter;
}
|
Base class keeping common code for implementations of the {@link ReactiveElasticsearchOperations} interface
independent of the used client.
@author Peter-Josef Meisch
@since 4.4
|
getElasticsearchConverter
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
Apache-2.0
|
public void setRefreshPolicy(@Nullable RefreshPolicy refreshPolicy) {
this.refreshPolicy = refreshPolicy;
}
|
Set the default {@link RefreshPolicy} to apply when writing to Elasticsearch.
@param refreshPolicy can be {@literal null}.
|
setRefreshPolicy
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
Apache-2.0
|
public void setEntityCallbacks(ReactiveEntityCallbacks entityCallbacks) {
Assert.notNull(entityCallbacks, "EntityCallbacks must not be null!");
this.entityCallbacks = entityCallbacks;
}
|
Set the {@link ReactiveEntityCallbacks} instance to use when invoking {@link ReactiveEntityCallbacks callbacks}
like the {@link ReactiveBeforeConvertCallback}. Overrides potentially existing {@link ReactiveEntityCallbacks}.
@param entityCallbacks must not be {@literal null}.
@throws IllegalArgumentException if the given instance is {@literal null}.
@since 4.0
|
setEntityCallbacks
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
Apache-2.0
|
public Mono<T> toEntity(@Nullable Document document) {
if (document == null) {
return Mono.empty();
}
return maybeCallbackAfterLoad(document, type, index)
.flatMap(documentAfterLoad -> {
// noinspection DuplicatedCode
T entity = reader.read(type, documentAfterLoad);
IndexedObjectInformation indexedObjectInformation = new IndexedObjectInformation(
documentAfterLoad.hasId() ? documentAfterLoad.getId() : null,
documentAfterLoad.getIndex(),
documentAfterLoad.hasSeqNo() ? documentAfterLoad.getSeqNo() : null,
documentAfterLoad.hasPrimaryTerm() ? documentAfterLoad.getPrimaryTerm() : null,
documentAfterLoad.hasVersion() ? documentAfterLoad.getVersion() : null);
entity = entityOperations.updateIndexedObject(
entity,
indexedObjectInformation,
converter,
routingResolver);
return maybeCallbackAfterConvert(entity, documentAfterLoad, index);
});
}
|
Convert a document into an entity
@param document the document to convert
@return a Mono of the entity
|
toEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/AbstractReactiveElasticsearchTemplate.java
|
Apache-2.0
|
default List<IndexedObjectInformation> bulkIndex(List<IndexQuery> queries, Class<?> clazz) {
return bulkIndex(queries, BulkOptions.defaultOptions(), clazz);
}
|
Bulk index all objects. Will do save or update.
@param queries the queries to execute in bulk
@param clazz the entity class
@return the information about the indexed objects
@throws org.springframework.data.elasticsearch.BulkFailureException with information about the failed operation
@since 4.1
|
bulkIndex
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
Apache-2.0
|
default List<IndexedObjectInformation> bulkIndex(List<IndexQuery> queries, IndexCoordinates index) {
return bulkIndex(queries, BulkOptions.defaultOptions(), index);
}
|
Bulk index all objects. Will do save or update.
@param queries the queries to execute in bulk
@return the information about of the indexed objects
@throws org.springframework.data.elasticsearch.BulkFailureException with information about the failed operation
|
bulkIndex
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
Apache-2.0
|
default void bulkUpdate(List<UpdateQuery> queries, IndexCoordinates index) {
bulkUpdate(queries, BulkOptions.defaultOptions(), index);
}
|
Bulk update all objects. Will do update.
@param queries the queries to execute in bulk
@throws org.springframework.data.elasticsearch.BulkFailureException with information about the failed operation
|
bulkUpdate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/DocumentOperations.java
|
Apache-2.0
|
@Nullable
default String convertId(@Nullable Object idValue) {
return idValue != null ? getElasticsearchConverter().convertId(idValue) : null;
}
|
Converts an idValue to a String representation. The default implementation calls
{@link ElasticsearchConverter#convertId(Object)}
@param idValue the value to convert
@return the converted value or {@literal null} if idValue is null
@since 5.0
|
convertId
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchOperations.java
|
Apache-2.0
|
@SuppressWarnings({ "unchecked", "rawtypes" })
<T> Entity<T> forEntity(T entity) {
Assert.notNull(entity, "Bean must not be null!");
if (entity instanceof Map) {
return new SimpleMappedEntity((Map<String, Object>) entity);
}
return MappedEntity.of(entity, context);
}
|
Creates a new {@link Entity} for the given bean.
@param entity must not be {@literal null}.
@return
|
forEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> AdaptableEntity<T> forEntity(T entity, ConversionService conversionService,
RoutingResolver routingResolver) {
Assert.notNull(entity, "Bean must not be null!");
Assert.notNull(conversionService, "ConversionService must not be null!");
if (entity instanceof Map) {
return new SimpleMappedEntity((Map<String, Object>) entity);
}
return AdaptableMappedEntity.of(entity, context, conversionService, routingResolver);
}
|
Creates a new {@link AdaptableEntity} for the given bean and {@link ConversionService} and {@link RoutingResolver}.
@param entity must not be {@literal null}.
@param conversionService must not be {@literal null}.
@param routingResolver the {@link RoutingResolver}, must not be {@literal null}
@return the {@link AdaptableEntity}
|
forEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
public <T> T updateIndexedObject(T entity,
IndexedObjectInformation indexedObjectInformation,
ElasticsearchConverter elasticsearchConverter,
RoutingResolver routingResolver) {
Assert.notNull(entity, "entity must not be null");
Assert.notNull(indexedObjectInformation, "indexedObjectInformation must not be null");
Assert.notNull(elasticsearchConverter, "elasticsearchConverter must not be null");
ElasticsearchPersistentEntity<?> persistentEntity = elasticsearchConverter.getMappingContext()
.getPersistentEntity(entity.getClass());
if (persistentEntity != null) {
PersistentPropertyAccessor<Object> propertyAccessor = persistentEntity.getPropertyAccessor(entity);
ElasticsearchPersistentProperty idProperty = persistentEntity.getIdProperty();
// Only deal with text because ES generated Ids are strings!
if (indexedObjectInformation.id() != null && idProperty != null
// isReadable from the base class is false in case of records
&& (idProperty.isReadable() || idProperty.getOwner().getType().isRecord())
&& idProperty.getType().isAssignableFrom(String.class)) {
propertyAccessor.setProperty(idProperty, indexedObjectInformation.id());
}
if (indexedObjectInformation.seqNo() != null && indexedObjectInformation.primaryTerm() != null
&& persistentEntity.hasSeqNoPrimaryTermProperty()) {
ElasticsearchPersistentProperty seqNoPrimaryTermProperty = persistentEntity.getSeqNoPrimaryTermProperty();
// noinspection ConstantConditions
propertyAccessor.setProperty(seqNoPrimaryTermProperty,
new SeqNoPrimaryTerm(indexedObjectInformation.seqNo(), indexedObjectInformation.primaryTerm()));
}
if (indexedObjectInformation.version() != null && persistentEntity.hasVersionProperty()) {
ElasticsearchPersistentProperty versionProperty = persistentEntity.getVersionProperty();
// noinspection ConstantConditions
propertyAccessor.setProperty(versionProperty, indexedObjectInformation.version());
}
var indexedIndexNameProperty = persistentEntity.getIndexedIndexNameProperty();
if (indexedIndexNameProperty != null) {
propertyAccessor.setProperty(indexedIndexNameProperty, indexedObjectInformation.index());
}
// noinspection unchecked
return (T) propertyAccessor.getBean();
} else {
EntityOperations.AdaptableEntity<T> adaptableEntity = forEntity(entity,
elasticsearchConverter.getConversionService(), routingResolver);
adaptableEntity.populateIdIfNecessary(indexedObjectInformation.id());
}
return entity;
}
|
Updates an entity after it is stored in Elasticsearch with additional data like id, version, seqno...
@param <T> the entity class
@param entity the entity to update
@param indexedObjectInformation the update information
@param elasticsearchConverter the converter providing necessary mapping information
@param routingResolver routing resolver to use
@return
|
updateIndexedObject
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
IndexCoordinates determineIndex(Entity<?> entity, @Nullable String index) {
return determineIndex(entity.getPersistentEntity(), index);
}
|
Determine index name and type name from {@link Entity} with {@code index} and {@code type} overrides. Allows using
preferred values for index and type if provided, otherwise fall back to index and type defined on entity level.
@param entity the entity to determine the index name. Can be {@literal null} if {@code index} and {@literal type}
are provided.
@param index index name override can be {@literal null}.
@return the {@link IndexCoordinates} containing index name and index type.
|
determineIndex
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
IndexCoordinates determineIndex(ElasticsearchPersistentEntity<?> persistentEntity, @Nullable String index) {
return index != null ? IndexCoordinates.of(index) : persistentEntity.getIndexCoordinates();
}
|
Determine index name and type name from {@link ElasticsearchPersistentEntity} with {@code index} and {@code type}
overrides. Allows using preferred values for index and type if provided, otherwise fall back to index and type
defined on entity level.
@param persistentEntity the entity to determine the index name. Can be {@literal null} if {@code index} and
{@literal type} are provided.
@param index index name override can be {@literal null}.
@return the {@link IndexCoordinates} containing index name and index type.
@since 4.1
|
determineIndex
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
default boolean isVersionedEntity() {
return false;
}
|
Returns whether the entity is versioned, i.e. if it contains a version property.
@return
|
isVersionedEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
default ElasticsearchPersistentEntity<?> getRequiredPersistentEntity() {
ElasticsearchPersistentEntity<?> persistentEntity = getPersistentEntity();
if (persistentEntity == null) {
throw new IllegalStateException("No ElasticsearchPersistentEntity available for this entity!");
}
return persistentEntity;
}
|
Returns the required {@link ElasticsearchPersistentEntity}.
@return
@throws IllegalStateException if no {@link ElasticsearchPersistentEntity} is associated with this entity.
|
getRequiredPersistentEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
@Override
public Object getId() {
return getBean().get(ID_FIELD);
}
|
Simple mapped entity without an associated {@link ElasticsearchPersistentEntity}.
@param <T>
@since 3.2
|
getId
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java
|
Apache-2.0
|
default boolean putMapping() {
return putMapping(createMapping());
}
|
Writes the mapping to the index for the class this IndexOperations is bound to.
@return {@literal true} if the mapping could be stored
@since 4.1
|
putMapping
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default boolean putMapping(Class<?> clazz) {
return putMapping(createMapping(clazz));
}
|
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
@since 4.1
|
putMapping
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
@Deprecated
@Nullable
default TemplateData getTemplate(String templateName) {
return getTemplate(new GetTemplateRequest(templateName));
}
|
gets an index template using the legacy Elasticsearch interface.
@param templateName the template name
@return TemplateData, {@literal null} if no template with the given name exists.
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
getTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
@Deprecated
default boolean existsTemplate(String templateName) {
return existsTemplate(new ExistsTemplateRequest(templateName));
}
|
check if an index template exists using the legacy Elasticsearch interface.
@param templateName the template name
@return {@literal true} if the index exists
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
existsTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default boolean existsIndexTemplate(String templateName) {
return existsIndexTemplate(new ExistsIndexTemplateRequest(templateName));
}
|
check if an index template exists.
@param templateName the template name
@return true if the index template exists
@since 5.1
|
existsIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default List<TemplateResponse> getIndexTemplate(String templateName) {
return getIndexTemplate(new GetIndexTemplateRequest(templateName));
}
|
Gets an index template.
@param templateName template name
@since 5.1
|
getIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default boolean deleteIndexTemplate(String templateName) {
return deleteIndexTemplate(new DeleteIndexTemplateRequest(templateName));
}
|
Deletes an index template.
@param templateName template name
@return true if successful
@since 5.1
|
deleteIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
@Deprecated
default boolean deleteTemplate(String templateName) {
return deleteTemplate(new DeleteTemplateRequest(templateName));
}
|
Deletes an index template using the legacy Elasticsearch interface (@see
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html).
@param templateName the template name
@return true if successful
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
deleteTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default List<IndexInformation> getInformation() {
return getInformation(getIndexCoordinates());
}
|
Gets the {@link IndexInformation} for the indices defined by {@link #getIndexCoordinates()}.
@return a list of {@link IndexInformation}
@since 4.2
|
getInformation
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/IndexOperations.java
|
Apache-2.0
|
default Mono<Void> bulkUpdate(List<UpdateQuery> queries, IndexCoordinates index) {
return bulkUpdate(queries, BulkOptions.defaultOptions(), index);
}
|
Bulk update all objects. Will do update. On errors returns with
{@link org.springframework.data.elasticsearch.BulkFailureException} with information about the failed operation
@param queries the queries to execute in bulk
@since 4.0
|
bulkUpdate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveDocumentOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveDocumentOperations.java
|
Apache-2.0
|
default Mono<Boolean> putMapping() {
return putMapping(createMapping());
}
|
Writes the mapping to the index for the class this IndexOperations is bound to.
@return {@literal true} if the mapping could be stored
|
putMapping
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Mono<Boolean> putMapping(Class<?> clazz) {
return putMapping(createMapping(clazz));
}
|
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
|
putMapping
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Mono<Settings> getSettings() {
return getSettings(false);
}
|
get the settings for the index
@return a {@link Mono} with a {@link Document} containing the index settings
|
getSettings
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Mono<Boolean> existsIndexTemplate(String indexTemplateName) {
return existsIndexTemplate(new ExistsIndexTemplateRequest(indexTemplateName));
}
|
Checks if an index template exists.
@param indexTemplateName the name of the index template
@return Mono with the value if the index template exists.
@since 5.1
|
existsIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Flux<TemplateResponse> getIndexTemplate(String indexTemplateName) {
return getIndexTemplate(new GetIndexTemplateRequest(indexTemplateName));
}
|
Get index template(s).
@param indexTemplateName the name of the index template
@return a {@link Flux} of {@link TemplateResponse}
@since 5.1
|
getIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Mono<Boolean> deleteIndexTemplate(String indexTemplateName) {
return deleteIndexTemplate(new DeleteIndexTemplateRequest(indexTemplateName));
}
|
Deletes an index template.
@param indexTemplateName the name of the index template
@return Mono with the value if the request was acknowledged.
@since 5.1
|
deleteIndexTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
@Deprecated
default Mono<TemplateData> getTemplate(String templateName) {
return getTemplate(new GetTemplateRequest(templateName));
}
|
gets an index template using the legacy Elasticsearch interface.
@param templateName the template name
@return Mono of TemplateData, {@literal Mono.empty()} if no template with the given name exists.
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
getTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
@Deprecated
default Mono<Boolean> existsTemplate(String templateName) {
return existsTemplate(new ExistsTemplateRequest(templateName));
}
|
Checks if an index template exists using the legacy Elasticsearch interface (@see
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html)
@param templateName the template name
@return Mono of {@literal true} if the template exists
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
existsTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
@Deprecated
default Mono<Boolean> deleteTemplate(String templateName) {
return deleteTemplate(new DeleteTemplateRequest(templateName));
}
|
Deletes an index template using the legacy Elasticsearch interface (@see
https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates-v1.html)
@param templateName the template name
@return Mono of {@literal true} if the template could be deleted
@since 4.1
@deprecated since 5.1, as the underlying Elasticsearch API is deprecated.
|
deleteTemplate
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
default Flux<IndexInformation> getInformation() {
return getInformation(getIndexCoordinates());
}
|
Gets the {@link IndexInformation} for the indices defined by {@link #getIndexCoordinates()}.
@return a flux of {@link IndexInformation}
@since 4.2
|
getInformation
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperations.java
|
Apache-2.0
|
public static Mono<Document> loadDocument(String path, String annotation) {
if (hasText(path)) {
return readFileFromClasspath(path).flatMap(s -> {
if (hasText(s)) {
return Mono.just(Document.parse(s));
} else {
return Mono.just(Document.create());
}
});
} else {
if (LOGGER.isInfoEnabled()) {
LOGGER.info(String.format("path in %s has to be defined. Using default instead.", annotation));
}
}
return Mono.just(Document.create());
}
|
loads a Document initialized with data from a given resource path.
@param path the path to load data from
@param annotation the annotation that had the resource path defined
@return the parsed document
@since 4.4
|
loadDocument
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ReactiveResourceUtil.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ReactiveResourceUtil.java
|
Apache-2.0
|
public static String readFileFromClasspath(String url) {
Assert.notNull(url, "url must not be null");
try (InputStream is = new ClassPathResource(url).getInputStream()) {
return StreamUtils.copyToString(is, Charset.defaultCharset());
} catch (Exception e) {
throw new ResourceFailureException("Could not load resource from " + url, e);
}
}
|
Read a {@link ClassPathResource} into a {@link String}.
@param url url the resource
@return the contents of the resource
|
readFileFromClasspath
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/ResourceUtil.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/ResourceUtil.java
|
Apache-2.0
|
public float getScore() {
return score;
}
|
@return the score for the hit.
|
getScore
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
public T getContent() {
return content;
}
|
@return the object data from the search.
|
getContent
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
public List<Object> getSortValues() {
return Collections.unmodifiableList(sortValues);
}
|
@return the sort values if the query had a sort criterion.
|
getSortValues
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
public Map<String, List<String>> getHighlightFields() {
return Collections.unmodifiableMap(highlightFields.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> Collections.unmodifiableList(entry.getValue()))));
}
|
@return the map from field names to highlight values, never {@literal null}
|
getHighlightFields
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
public List<String> getHighlightField(String field) {
Assert.notNull(field, "field must not be null");
return Collections.unmodifiableList(highlightFields.getOrDefault(field, Collections.emptyList()));
}
|
gets the highlight values for a field.
@param field must not be {@literal null}
@return possibly empty List, never null
|
getHighlightField
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
@Nullable
public SearchHits<?> getInnerHits(String name) {
return innerHits.get(name);
}
|
returns the {@link SearchHits} for the inner hits with the given name. If the inner hits could be mapped to a
nested entity class, the returned data will be of this type, otherwise
{{@link org.springframework.data.elasticsearch.core.document.SearchDocument}} instances are returned in this
{@link SearchHits} object.
@param name the inner hits name
@return {@link SearchHits} if available, otherwise {@literal null}
|
getInnerHits
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
public Map<String, SearchHits<?>> getInnerHits() {
return innerHits;
}
|
@return the map from inner_hits names to inner hits, in a {@link SearchHits} object, never {@literal null}
@since 4.1
|
getInnerHits
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
@Nullable
public String getRouting() {
return routing;
}
|
@return the routing for this SearchHit, may be {@literal null}.
@since 4.2
|
getRouting
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
@Nullable
public Explanation getExplanation() {
return explanation;
}
|
@return the explanation for this SearchHit.
@since 4.2
|
getExplanation
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
@Nullable
public Map<String, Double> getMatchedQueries() {
return matchedQueries;
}
|
@return the matched queries for this SearchHit.
|
getMatchedQueries
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHit.java
|
Apache-2.0
|
private SearchHits<?> mapInnerDocuments(SearchHits<SearchDocument> searchHits, Class<T> type) {
if (searchHits.isEmpty()) {
return searchHits;
}
try {
ElasticsearchPersistentEntity<?> persistentEntityForType = mappingContext.getPersistentEntity(type);
NestedMetaData nestedMetaData = searchHits.getSearchHit(0).getContent().getNestedMetaData();
ElasticsearchPersistentEntityWithNestedMetaData persistentEntityWithNestedMetaData = getPersistentEntity(
persistentEntityForType, nestedMetaData);
if (persistentEntityWithNestedMetaData.entity != null) {
List<SearchHit<Object>> convertedSearchHits = new ArrayList<>();
Class<?> targetType = persistentEntityWithNestedMetaData.entity.getType();
// convert the list of SearchHit<SearchDocument> to list of SearchHit<Object>
searchHits.getSearchHits().forEach(searchHit -> {
SearchDocument searchDocument = searchHit.getContent();
Object targetObject = converter.read(targetType, searchDocument);
convertedSearchHits.add(new SearchHit<>(searchDocument.getIndex(), //
searchDocument.getId(), //
searchDocument.getRouting(), //
searchDocument.getScore(), //
searchDocument.getSortValues(), //
searchDocument.getHighlightFields(), //
searchHit.getInnerHits(), //
getPersistentEntity(persistentEntityForType, //
searchHit.getContent().getNestedMetaData()).nestedMetaData, //
searchHit.getExplanation(), //
searchHit.getMatchedQueries(), //
targetObject));
});
String scrollId = null;
if (searchHits instanceof SearchHitsImpl<?> searchHitsImpl) {
scrollId = searchHitsImpl.getScrollId();
}
return new SearchHitsImpl<>(searchHits.getTotalHits(),
searchHits.getTotalHitsRelation(),
searchHits.getMaxScore(),
searchHits.getExecutionDuration(),
scrollId,
searchHits.getPointInTimeId(),
convertedSearchHits,
searchHits.getAggregations(),
searchHits.getSuggest(),
searchHits.getSearchShardStatistics());
}
} catch (Exception e) {
throw new UncategorizedElasticsearchException("Unable to convert inner hits.", e);
}
return searchHits;
}
|
try to convert the SearchDocument instances to instances of the inner property class.
@param searchHits {@link SearchHits} containing {@link Document} instances
@param type the class of the containing class
@return a new {@link SearchHits} instance containing the mapped objects or the original inout if any error occurs
|
mapInnerDocuments
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHitMapping.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHitMapping.java
|
Apache-2.0
|
private ElasticsearchPersistentEntityWithNestedMetaData getPersistentEntity(
@Nullable ElasticsearchPersistentEntity<?> persistentEntity, @Nullable NestedMetaData nestedMetaData) {
NestedMetaData currentMetaData = nestedMetaData;
List<NestedMetaData> mappedNestedMetaDatas = new LinkedList<>();
while (persistentEntity != null && currentMetaData != null) {
ElasticsearchPersistentProperty persistentProperty = persistentEntity
.getPersistentPropertyWithFieldName(currentMetaData.getField());
if (persistentProperty == null) {
persistentEntity = null;
} else {
persistentEntity = mappingContext.getPersistentEntity(persistentProperty.getActualType());
mappedNestedMetaDatas.add(0,
NestedMetaData.of(persistentProperty.getName(), currentMetaData.getOffset(), null));
currentMetaData = currentMetaData.getChild();
}
}
NestedMetaData mappedNestedMetaData = mappedNestedMetaDatas.stream().reduce(null,
(result, nmd) -> NestedMetaData.of(nmd.getField(), nmd.getOffset(), result));
return new ElasticsearchPersistentEntityWithNestedMetaData(persistentEntity, mappedNestedMetaData);
}
|
find a {@link ElasticsearchPersistentEntity} following the property chain defined by the nested metadata
@param persistentEntity base entity
@param nestedMetaData nested metadata
@return A {@link ElasticsearchPersistentEntityWithNestedMetaData} containing the found entity or null together with
the {@link NestedMetaData} that has mapped field names.
|
getPersistentEntity
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHitMapping.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHitMapping.java
|
Apache-2.0
|
default boolean hasSearchHits() {
return !getSearchHits().isEmpty();
}
|
@return whether the {@link SearchHits} has search hits.
|
hasSearchHits
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
Apache-2.0
|
default boolean hasSuggest() {
return getSuggest() != null;
}
|
@return wether the {@link SearchHits} has a suggest response.
@since 4.3
|
hasSuggest
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
Apache-2.0
|
default Iterator<SearchHit<T>> iterator() {
return getSearchHits().iterator();
}
|
@return an iterator for {@link SearchHit}
|
iterator
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchHits.java
|
Apache-2.0
|
default long count(Query query, IndexCoordinates index) {
return count(query, null, index);
}
|
Return number of elements found by given query.
@param query the query to execute
@param index the index to run the query against
@return count
|
count
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
Apache-2.0
|
@Nullable
default <T> SearchHit<T> searchOne(Query query, Class<T> clazz) {
List<SearchHit<T>> content = search(query, clazz).getSearchHits();
return content.isEmpty() ? null : content.get(0);
}
|
Execute the query against elasticsearch and return the first returned object.
@param query the query to execute
@param clazz the entity clazz used for property mapping and indexname extraction
@return the first found object
|
searchOne
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
Apache-2.0
|
@Nullable
default <T> SearchHit<T> searchOne(Query query, Class<T> clazz, IndexCoordinates index) {
List<SearchHit<T>> content = search(query, clazz, index).getSearchHits();
return content.isEmpty() ? null : content.get(0);
}
|
Execute the query against elasticsearch and return the first returned object.
@param query the query to execute
@param clazz the entity clazz used for property mapping
@param index the index to run the query against
@return the first found object
|
searchOne
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/SearchOperations.java
|
Apache-2.0
|
default ProjectionFactory getProjectionFactory() {
return new SpelAwareProxyProjectionFactory();
}
|
Get the configured {@link ProjectionFactory}. <br />
<strong>NOTE</strong> Should be overwritten in implementation to make use of the type cache.
@since 3.2
|
getProjectionFactory
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
Apache-2.0
|
default String convertId(Object idValue) {
Assert.notNull(idValue, "idValue must not be null!");
if (!getConversionService().canConvert(idValue.getClass(), String.class)) {
return idValue.toString();
}
String converted = getConversionService().convert(idValue, String.class);
if (converted == null) {
return idValue.toString();
}
return converted;
}
|
Convert a given {@literal idValue} to its {@link String} representation taking potentially registered
{@link org.springframework.core.convert.converter.Converter Converters} into account.
@param idValue must not be {@literal null}.
@return never {@literal null}.
@since 3.2
|
convertId
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
Apache-2.0
|
default Document mapObject(@Nullable Object source) {
Document target = Document.create();
if (source != null) {
write(source, target);
}
return target;
}
|
Map an object to a {@link Document}.
@param source the object to map
@return will not be {@literal null}.
|
mapObject
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchConverter.java
|
Apache-2.0
|
@Override
public UUID convert(String source) {
return UUID.fromString(source);
}
|
{@link Converter} to read a {@link UUID} from its {@link String} representation.
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
@Override
public String convert(UUID source) {
return source.toString();
}
|
{@link Converter} to write a {@link UUID} to its {@link String} representation.
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
@Override
public BigDecimal convert(Double source) {
return NumberUtils.convertNumberToTargetClass(source, BigDecimal.class);
}
|
{@link Converter} to read a {@link BigDecimal} from a {@link Double} value.
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
@Override
public Double convert(BigDecimal source) {
return NumberUtils.convertNumberToTargetClass(source, Double.class);
}
|
{@link Converter} to write a {@link BigDecimal} to a {@link Double} value.
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
@Override
public String convert(byte[] source) {
return Base64.getEncoder().encodeToString(source);
}
|
{@link Converter} to write a byte[] to a base64 encoded {@link String} value.
@since 4.0
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
@Override
public byte[] convert(String source) {
return Base64.getDecoder().decode(source);
}
|
{@link Converter} to read a byte[] from a base64 encoded {@link String} value.
@since 4.0
|
convert
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchCustomConversions.java
|
Apache-2.0
|
public static ElasticsearchDateConverter of(DateFormat dateFormat) {
Assert.notNull(dateFormat, "dateFormat must not be null");
return of(dateFormat.name());
}
|
Creates an ElasticsearchDateConverter for the given {@link DateFormat}.
@param dateFormat must not be @{literal null}
@return converter
|
of
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java
|
Apache-2.0
|
public static ElasticsearchDateConverter of(String pattern) {
Assert.hasText(pattern, "pattern must not be empty");
String[] subPatterns = pattern.split("\\|\\|");
return converters.computeIfAbsent(subPatterns[0].trim(), p -> new ElasticsearchDateConverter(forPattern(p)));
}
|
Creates an ElasticsearchDateConverter for the given pattern.
@param pattern must not be {@literal null}
@return converter
|
of
|
java
|
spring-projects/spring-data-elasticsearch
|
src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java
|
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/convert/ElasticsearchDateConverter.java
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.