spring-data-elasticsearch | Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar S | Microservice library
kandi X-RAY | spring-data-elasticsearch Summary
kandi X-RAY | spring-data-elasticsearch Summary
Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the property value converter
- Returns a list of Elasticsearch date converters
- Returns a DateFormatter for the given pattern
- Initializes the value converter from the annotation
- Execute a query with multiple queries
- Executes a query on a list of classes
- Execute a multi search query
- Gets the specified index
- Create a request for an index
- Builds a native search query
- Gets the sort builder
- Gets the completion suggestion from a list of suggestions
- Writes the type and parameters to an ObjectNode
- Writes the given value as a string
- Get the health of a cluster
- Gets a request for term vectors
- Reads the specified value as a Range object
- A delete request
- Updates an indexed object
- Registers the given property
- Gets a request
- Performs an index operation
- Creates a new ElasticsearchRestClient from clientConfiguration
- Executes the query
- Create a TemporalQuery for a given temporal type
- Start the downloader
spring-data-elasticsearch Key Features
spring-data-elasticsearch Examples and Code Snippets
# spring boot
compile 'org.springframework.boot:spring-boot:2.0.0.M2'
# elasticsearch
compile 'org.elasticsearch:elasticsearch:5.5.0'
compile 'org.elasticsearch.client:transport:5.5.0'
# spring-data-elasticsearch for spring boot
compile
Community Discussions
Trending Discussions on spring-data-elasticsearch
QUESTION
I am using Springboot with MongoDb and Elasticsearch for my project. When my Elasticsearch server is running then my Springboot application is working fine but when the Elasticsearch server is stopped, my Springboot application also fails to start. According to my project's requirements, our Springboot application should still be running even though the Elasticsearch server fails to start as the majority of our APIs are built on Springboot and MongoDb and only a few depend on Elasticsearch. Is there any way I can achieve this?
Elasticsearch configuration
...ANSWER
Answered 2022-Apr-05 at 08:51You can mark them beans with @Lazy so spring will not construct them on application startup. It will construct them when you use them runtime.
please see this documentation
https://memorynotfound.com/lazy-initialize-autowired-dependencies-with-lazy-annotation/
QUESTION
Currently we are on spring-data-elasticsearch 3.2.6 + elasticsearch 6.8. We are moving to new elasticsearch 7.x. Do I have to update spring-data-elasticsearch to 4.x? We only use ElasticsearchRepository in spring-data-elasticsearch. And we don't need to use any new feature in elasticsearch 7.x.
If we are moving to elasticsearch 8.x in the future, do I need update spring-data-elasticsearch ?
Update:
What Elasticsearch client does Spring-Data-Elasticsearch use under the hood?
All methods in the `ElasticsearchRepository` are deprecated. What should do I use?
I found some discussions in above threads. Here is my summary.
- Operations with Templates:
ElasticsearchTemplate implements ElasticSearchOperation. It uses TransportClient(which is deprecated in ES 7 and has been removed in ES8)
ElasticsearchRestTemplate implements ElasticSearchOperation. It uses high level client(which is deprecated in ES 7.16.0. It will be removed in future. @Deprecated(since = "7.16.0", forRemoval = true) )
ReactiveElasticsearchTemplate implements ReactiveElasticsearchOperations. It uses Reactive Client.
- Repository
ElasticsearchRepository uses TransportClient as default. All methods in the ElasticsearchRepository are deprecated now.
Reactive Elasticsearch repository builds on ReactiveElasticsearchOperations.
Due to underlying TransportClient or HigLevelRestClient has been deprecated, can I conclude that the correct way is to use Reactive Client(ReactiveElasticsearchTemplate or Reactive Elasticsearch repository) ?
...ANSWER
Answered 2022-Mar-24 at 16:54The new Elasticsearch would be 8.
Val already put the link to the compatibility matrix in his comment.
Version 3.2.6 is pretty outdated (March 25 2020) and out of support since October 2020.
The first thing you can try is to see if your application works with a 7 cluster - although I doubt that, I can't tell you exactly what had changed in the API, but there was quite some stuff.
What you should not do is putting newer Elasticsearch libraries on the classpath than the ones that Spring Data Elasticsearch was built with, this will in most cases make problems.
But I'd recommend to upgrade your application anyway and keep it regularly up to date.
As for future upgrade to version 8: It is possible to send a compatibility header in your requests (this can be done in Spring Data Elasticsearch 4) and the Elasticsearch cluster should respond in a format that is compatible with a client expecting version 7. I wrote should, because it does not conform to this in every case - I reported one case that is fixed now. But I wouldn't rely on that.
Again, please update your application and keep it up to date, not only because of Spring Data Elasticsearch, but also because these updates always include bug and/or security fixes.
QUESTION
I was following this tutorial: https://www.youtube.com/watch?v=IiZZAu2Qtp0&ab_channel=LiliumCode
and the only changes I made were that I was using maven with eclipse instead. The rest of the code is exactly the same. When I run the app I get:
...ANSWER
Answered 2022-Mar-15 at 09:47ConnectionClosedException seems to hint at the fact that your Spring Boot application cannot establish a connection to your ES cluster.
It looks like you're using ES8, which has SSL/TLS on by default, so you would need to configure your Spring Boot application to use SSL instead.
At 6:00 into the video, elasticsearch.url
in application.properties
should be https://localhost:9200
instead of just localhost:9200
.
However, as of March 15th 2022, it doesn't seem like ES 8 is supported by Spring Data ES yet, you might need to revert to the ES 7.15+ release.
QUESTION
I am using Spring-Data-Elasticsearch and I have the following queries,
...ANSWER
Answered 2022-Feb-06 at 18:51Spring Data Elasticsearch internally builds a CriteriaQuery
for a repository method that has StartingWith in in it's name:
QUESTION
I'm running on an aws-elasticsearch (with OpenSearch 1.1.x) service and im trying to connect with it since an spring application using spring-data-elasticsearch, according to the doc i configured the way it says.
From aws i used an ssh tunnel from my aws account.
i used this command:
...ANSWER
Answered 2021-Oct-18 at 05:15You have to configure to use SSL for the reactive client with one of the usingSsl()
methods:
QUESTION
Before elasticsearch 7.16, the ElasticsearchOperations
could be formulated with RestHighLevelClient
ANSWER
Answered 2022-Jan-22 at 07:44I am currently working on integrating the new Elasticsearch client in Spring Data Elasticsearch. We will in the next minor release (4.4) still the RestHighLevelClient
but provide as an optional alternative the possibility to use the new client.
The new client does not yet have the same functionality as the RHLC and still has some error (you might want to have a look at it's issue list), so we cannot already replace it, but the most important reason not to use it in the current version is that the new Client pulls in jakarta
packages instead of javax
and switching by default to the new client would break many existing applications.
A full replacement cannot be done before Spring Data Elasticsearch 5.0, which will use Spring 6, be integrated in Spring Boot 3 as Jakarta EE9 will be only with these releases.
In my opinion, Elasticsearch should not have deprecated the RHLC in a switch of a minor version (ES 7.15 -> 7.16) while providing an incomplete alternative that introduces breaking changes.
So for the time being we have to live with the fact that Spring Data Elasticsearch needs to use a deprecated class.
QUESTION
TL;DR : How to switch elastic search hosts at runtime using spring-data-elasticsearch?
We have a spring boot application (v : 2.5.2) using spring data elasticsearch (v: 4.2.2).
I am using java configurations to initialize ES connection as mentioned in High Level Rest Client section of spring's documentation.
We have a requirement where we need to change the elasticsearch hosts at runtime and not manually restart our servers.
I tried restarting spring IOC on hostname config change using something similar to spring actuator's RestartEndpoint. But this seems to work only in spring's embedded tomcat and not with the external tomcat that we use.
Is there an alternate way to do this?
[This is required in case there is a disaster and we need to switch to backup]
...ANSWER
Answered 2022-Jan-08 at 17:19Nothing out of the box.
One idea (I did not try it out): You'd need to create your own implementation of the ElasticsearchOperations
interface, lets call it MyOperations
and return that from the AbstractElasticsearchConfiguration#elasticsearchOperations()
method which your configuration inherits. In this MyOperations
implementation (which is a singleton Spring bean), you'd create a delegate ElasticsearchOperations
with the same code like in the configuration class that is connected to normal cluster. Every method in your implementation then delegates to the corresponding method of the delegate.
In the failure case, your implementation would create a new delegate that now connects to the secondary cluster and replace the first one with it. Or create both and implement a toggle feature to switch between the two.
QUESTION
I was comparing elastic search results with refresh_interval 1s and 30s, when Refresh Policy was set to None by indexing 2000 documents in the same rate. but there was not much difference between their indexing speed.
using version:
...ANSWER
Answered 2021-Dec-11 at 21:33These are different things. refresh
(aka refreshPolicy
) lets you tell ES to start a refresh after indexing and wait for it to complete (wait_for
) or not wait (true
) or just leave cluster do its job (false
, None
, default).
refresh_interval
makes most sense when refresh
is not enabled and it defines how exactly cluster "does its job". Refresh is quite heavy operation so it's recommended to increase it or even disable (set to -1
) for the time of indexing.
If you haven't noticed performance improvement while changing refresh_interval
then you probably haven't maxed out indexing capacity on ES side: bulk size tuning, multiple indexing threads/machines, etc (see Tune for indexing speed)
QUESTION
I am getting the following error while searching data from elasticsearch through spring data jpa
...ANSWER
Answered 2021-Nov-23 at 15:15The ccs_minimize_roundtrips
parameter has been added in 7.0.0-beta1, so my take is that you're using a client version that is more recent (i.e. 7+) than your Elasticsearch server version.
According to your Maven dependencies, spring-data-elasticsearch:3.2.3
depends on Elastic 6.8.12, so there is a small disconnect between the client and server versions.
QUESTION
I am using spring-data-elasticsearch
and I have a class as follows,
ANSWER
Answered 2021-Aug-31 at 04:46Your top level query should be a bool query with two entries as must:
- the first for the
name
that would be the one you already have. - the second for the "status.id" property
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-data-elasticsearch
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page