Spring Data Elasticsearch

repository·main·Indexed 25 days ago

https://github.com/spring-projects/spring-data-elasticsearch

Integration 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.

Tokens
26.9K
Snippets
58
Records
152
Agent score
84%

What's inside Spring Data Elasticsearch

  1. Overview of Spring Data Elasticsearch features

    main

    Spring 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: ElasticsearchTemplate and ReactiveElasticsearchTemplate for 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 Repository interfaces, including support for custom query methods.

    For most data-oriented tasks, it is recommended to use either the [Reactive]ElasticsearchTemplate or the Repository support.

  2. New features in Spring Data Elasticsearch 4.0

    main

    The 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 ObjectMapper in favor of MappingElasticsearchConverter.
    • API Cleanup: Cleaned up *Operations interfaces to align with Elasticsearch API and other Spring Data modules.
    • Search Result Metadata: Introduced SearchHit<T> (for document metadata like _sortValues) and SearchHits<T> (for result metadata like max_score).
    • Paged Results: Introduced SearchPage<T> to represent paged results.
    • Geo Distance Sorting: Introduced GeoDistanceOrder for sorting by geographical distance.
    • Auditing & Callbacks: Implemented Auditing Support and lifecycle entity callbacks.
  3. New features in Spring Data Elasticsearch 4.3

    main

    The 4.3 release includes the following updates:

    • Elasticsearch Upgrade: Supports Elasticsearch 7.15.2.
    • Runtime Fields: Allows runtime_fields to 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.Order with Elasticsearch-specific parameters.
  4. Understand the new Operations interfaces

    main

    In version 4.0, the monolithic ElasticsearchOperations interface 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).

    ElasticsearchOperations now extends DocumentOperations and SearchOperations, and provides access to an IndexOperations instance.

  5. New features in Spring Data Elasticsearch 5.4

    main

    The 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 @InnerField and @Field annotations.
    • Elasticsearch SQL: Added support for Elasticsearch SQL.
    • Execution Duration: Added support for retrieving request executionDuration.
  6. New features in Spring Data Elasticsearch 5.3

    main

    The 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 SearchHit class.
    • 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_child and has_parent queries.
  7. New features in Spring Data Elasticsearch 5.5

    main

    The 5.5 release includes the following updates:

    • Elasticsearch Upgrade: Supports Elasticsearch 8.18.1.
    • @SearchTemplateQuery: Added support for the @SearchTemplateQuery annotation on repository methods.
    • Scripted Fields: Scripted field properties of type collection can now be populated from scripts returning arrays.