Spring Data Elasticsearch
repository·main·Indexed 25 days ago
https://github.com/spring-projects/spring-data-elasticsearchIntegration with the Elasticsearch search engine providing a POJO-centric model and a Repository-style data access layer. Features include support for imperative and reactive stacks, ElasticsearchTemplate and ReactiveElasticsearchTemplate, automatic exception translation, and Java-based Query DSLs. Includes configuration for Rest5Client and legacy RestClient, as well as auditing support via @EnableElasticsearchAuditing and @EnableReactiveElasticsearchAuditing.
What's inside Spring Data Elasticsearch
- Spring Data Elasticsearch provides repository support for the Elasticsearch database. It allows developers to access Elasticsearch data sources using a consistent programming model, easing the development of applications that require Elasticsearch integration.
Overview of Spring Data Elasticsearch features
mainSpring Data Elasticsearch provides a comprehensive integration for working with Elasticsearch in Spring applications. Key features include:
- Client Configuration: Spring configuration support for various Elasticsearch clients.
- Template Helpers:
ElasticsearchTemplateandReactiveElasticsearchTemplatefor object mapping between Elasticsearch index operations and POJOs. - Exception Translation: Automatic translation of Elasticsearch-specific exceptions into Spring's portable Data Access Exception Hierarchy.
- Object Mapping: Feature-rich object mapping integrated with Spring's Conversion Service, supporting annotation-based mapping metadata.
- Query DSLs: Java-based DSLs for queries, criteria, and updates.
- Repository Support: Automatic implementation of both imperative and reactive
Repositoryinterfaces, including support for custom query methods.
For most data-oriented tasks, it is recommended to use either the
[Reactive]ElasticsearchTemplateor theRepositorysupport.New features in Spring Data Elasticsearch 4.0
mainThe 4.0 release includes the following updates:
- Spring Upgrade: Uses Spring 5.2.
- Elasticsearch Upgrade: Supports Elasticsearch 7.6.2.
- TransportClient Deprecation: Deprecated usage of
TransportClient. - Mapping Types: Implements most mapping types available for index mappings.
- Mapping Converter: Removed Jackson
ObjectMapperin favor ofMappingElasticsearchConverter. - API Cleanup: Cleaned up
*Operationsinterfaces to align with Elasticsearch API and other Spring Data modules. - Search Result Metadata: Introduced
SearchHit<T>(for document metadata like_sortValues) andSearchHits<T>(for result metadata likemax_score). - Paged Results: Introduced
SearchPage<T>to represent paged results. - Geo Distance Sorting: Introduced
GeoDistanceOrderfor sorting by geographical distance. - Auditing & Callbacks: Implemented Auditing Support and lifecycle entity callbacks.
New features in Spring Data Elasticsearch 4.3
mainThe 4.3 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 7.15.2.
- Runtime Fields: Allows
runtime_fieldsto be defined in the index mapping. - Range Types: Added native support for range field types using a range object.
- Nullable Property Search: Added repository search for nullable or empty properties.
- Custom Converters: Enabled custom converters for single fields.
- Custom Sort Order: Allows supplying a custom
Sort.Orderwith Elasticsearch-specific parameters.
New features in Spring Data Elasticsearch 4.2
mainThe 4.2 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 7.10.0.
- Custom Routing: Added support for custom routing values.
Understand the new Operations interfaces
mainIn version 4.0, the monolithic
ElasticsearchOperationsinterface has been split into specialized interfaces to align with the Elasticsearch API:DocumentOperations: Functions related to documents (e.g.,save,delete).SearchOperations: Functions for searching in Elasticsearch.IndexOperations: Functions for index management (e.g.,create, mapping creation).
ElasticsearchOperationsnow extendsDocumentOperationsandSearchOperations, and provides access to anIndexOperationsinstance.New features in Spring Data Elasticsearch 5.4
mainThe 5.4 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 8.15.3.
- Mapped Type Customization: You can customize the mapped type name for
@InnerFieldand@Fieldannotations. - Elasticsearch SQL: Added support for Elasticsearch SQL.
- Execution Duration: Added support for retrieving
request executionDuration.
Configure Elasticsearch Object Mapping
mainSpring Data Elasticsearch uses theMappingElasticsearchConverterto map Java domain entities to JSON documents in Elasticsearch. You can use a Metamodel-based approach by annotating your domain classes to define how they are read from and written to the database.New features in Spring Data Elasticsearch 5.3
mainThe 5.3 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 8.13.2.
- Highlighting: Added support for highlight queries in highlighting.
- Shard Statistics: Added shard statistics to the
SearchHitclass. - Multi Search Template: Added support for the multi search template API.
- SpEL in @Query: Added support for SpEL in
@Query. - Field Aliases: Added support for field aliases in the index mapping.
- Parent/Child Queries: Added support for
has_childandhas_parentqueries.
New features in Spring Data Elasticsearch 5.1
mainThe 5.1 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 8.7.1.
- TLS Configuration: Allows specification of the TLS certificate when connecting to an Elasticsearch 8 cluster.
New features in Spring Data Elasticsearch 5.0
mainThe 5.0 release includes the following updates:
- Java Upgrade: Upgraded to Java 17 baseline.
- Spring Upgrade: Upgraded to Spring Framework 6.
- Elasticsearch Upgrade: Supports Elasticsearch 8.5.0.
- Client Upgrade: Switched to the new Elasticsearch client library.
New features in Spring Data Elasticsearch 5.5
mainThe 5.5 release includes the following updates:
- Elasticsearch Upgrade: Supports Elasticsearch 8.18.1.
- @SearchTemplateQuery: Added support for the
@SearchTemplateQueryannotation on repository methods. - Scripted Fields: Scripted field properties of type collection can now be populated from scripts returning arrays.