Spring-Data-Elasticsearch | : cn : Spring-Data-Elasticsearch官方文档的中文翻译版本,翻译不好请见谅,欢迎提issue
kandi X-RAY | Spring-Data-Elasticsearch Summary
kandi X-RAY | Spring-Data-Elasticsearch Summary
:cn:Spring-Data-Elasticsearch官方文档的中文翻译版本,翻译不好请见谅,欢迎提issue
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Spring-Data-Elasticsearch
Spring-Data-Elasticsearch Key Features
Spring-Data-Elasticsearch Examples and Code Snippets
Community Discussions
Trending Discussions on Spring-Data-Elasticsearch
QUESTION
I'm now using spring-boot
and spring-data-elasticsearch
for my java project.
I have to count the number of users who reports some data per day, so I created a custom query for it,
...ANSWER
Answered 2021-Jun-07 at 16:31- You can use
@CountQuery
instead of@Query
(or add the parametercount = true
to the@Query
annotation) - and change the return value of the repository method tolong
. - This should work with query derivation and a method name like
long countByUsernameAndCreatedTimeBetween(String username, Instant from, Instant two)
- I have not tested this. And you would need to calculate the date parameters
I would create a custom repository fragment with a method long userWithinADay(String user)
and in the implementation I would create a CriteriaQuery
for the name and the dates and pass that to one of the ElasticsearchOperations.count()
methods.
Edit:
@CountQuery
was added in Spring Data Elasticsearch 4.2.
QUESTION
I am running a small demo spring-boot application where I want to connect my url routes with elasticsearch queries. The app starts up just fine with those gradle dependencies:
...ANSWER
Answered 2021-May-27 at 11:18From the stacktrace follows that you should add a missing dependency to spring-web-reactive to your Gradle config:
QUESTION
I'm getting the following exception when trying to use a named query with Spring Data Elasticsearch.
...ANSWER
Answered 2021-May-14 at 10:32To answer your second question (Is it possible for a named query to return a SearchPage?): This is a bug that it does not work with @Query
annotated methods. I fixed that yesterday for the main, 4.2.x, 4.1.x and 4.0.x branches so it will work when the next service releases are out.
To answer the first one, I will need to do some research and tests before I can say anything about that - it would be great if it would work. I think I' can give more information later this weekend.
Edit/Addition:
The query derivation from the method name is based on the properties of the Java class and is done in the Spring Data base which knows nothing about these inner fields that only exist in Elasticsearch.
But you can use the following custom repository fragment:
QUESTION
I have an application which consists of a backend (spring boot) and a search engine (elasticsearch). After I deployed it into OCP, Initially I tested the connection between the two using the command "curl" to elasticsearch service (https://service-name.namespace.svc.cluster.local:9200)
from backend pod and it worked. Here's the picture:
However, when I try to access elasticsearch from within the deployed backend application, an error message appears as below:
And here are my configuration in Spring Boot to connect with Elasticsearch that I did:
...ANSWER
Answered 2021-May-08 at 18:09I think the elasticsearch builder .connectedTo
method requires the format host:port
, i.e. without the protocol.
So try:
QUESTION
I've searched Stack and google looking for an answer to no luck. So I'm hoping someone can help me here.
I have a Spring Boot API which is currently using Tomcat, now I've read about some of the performance improvements in Undertow so I wanted to give it a go and see for myself.
Now, I've removed my spring-boot-web-starter dependancy and added undertow however I'm getting the following errors in a few classes and I can't seem to find how to resolve them:
...ANSWER
Answered 2021-May-03 at 15:08By excluding spring-boot-starter-web
you did exclude all its dependencies, which are necessary to run a Spring Boot project in a servlet environment. Most notably you did exclude spring-web
, which contains most of the classes you find in the error messages.
As its name suggests spring-boot-starter-web
isn't centered around Tomcat, only its dependency spring-boot-starter-tomcat
is. So you should exclude the latter artifact and include spring-boot-starter-undertow
to pull the necessary Undertow dependencies into the project:
QUESTION
I have been trying to use ReactiveElasticsearchClient to index some documents in my spring application. My application is stuck indefinitely when I am trying to run the jar with command java -jar reactive-es-1.0-SNAPSHOT.jar application.ReactiveEsApplication
Here's the pom.xml file
...ANSWER
Answered 2021-Apr-30 at 16:02The problem is that you are mixing versions of the libraries which do not match and do not work together.
You define the parent as Spring Boot 2.3.5, a version which uses Spring 5.2 but later define the webflux version to 5.3.6. The Spring Data Elasticsearch version 4.1.8 also is built with Spring 5.3.2. I didn't check the recactor and netty versions in detail, but there probably is some conflict as well - it seems that in your pom you defined these dependencies with the versions from Spring Boot 2.4.5 but keep the parent version on 2.3.5.
Your application runs with the following pom (I set the parent to 2.4.5 and removed unneeded explicit dependencies):
QUESTION
I have a question about the relationships between High Level REST Client
and spring-data-elasticsearch
.
In my spring-boot project, I created the RestClientConfig
for the connection,
ANSWER
Answered 2021-Apr-27 at 18:35Spring Data Elasticsearch never closes the client as it does not create it, you create it in your configuraiton.
And like the linked document states:
you should close the high-level client when you are well and truly done with it
Spring Data Elasticsearch cannot know if and when your application does not need the connection to Elasticsearch any more.
So you might keep a reference to the client and close it if you think you really don't need it. But any calls to ElasticsearchOperations or repositories will fail after that.
Actually I never heard of a problem because of wasted resources of a single instance of this class in an application, I'd say don't bother with closing it.
QUESTION
We have a few similar queries and I wanted to do some templating based on parameters. Recently I've found that elastic supports search templates so I'm wondering whether this is supported by spring-data-elasticearch.
Currently my query looks something like:
...ANSWER
Answered 2021-Mar-16 at 20:51No, Spring Data Elasticsearch currently does not support search templates.
Edit 16.03.2021: search template support has been added to the ReactiveElasticsearchClient
in Spring Data Elasticsearch by a pull request from bilak. Thanks for that.
QUESTION
I am using spring-data-elasticsearch. I have constructed most of the query conditions using criteria with lots of sub-criteria. Now I want to include a simple query condition for a nested field. But criteria corms query using uery_string API which is not working for nested fields. I am expecting Nested query.
How to support this using Criteria without NativeSearchQuery?
Nested Mapping
...ANSWER
Answered 2021-Apr-05 at 15:00Currently Spring Data Elasticsearch's CriteriaQuery
does not support creating nested queries.
The query that is created currently with your example code is (cleaning out irrelevant parts):
QUESTION
I'm seriously struggling with a query in Elastic search so i'm hoping someone here can help me.
So I have an Index in elastic search which stores some basic info on a user. Then I have my Spring Boot API which allows a client to search on said index.
In my app, when a user signs up they get to choose a displayname on the site. Now when they type out a display name I want to be able to check elastic and tell them if its taken or not.
However, where I'm struggling is, say I have One user in my Index with the DisplayName of "John Boy", now user two signs up and wants the display name "Boy". When I do a search to see if "Boy" is taken, I get back "John Boy". I want it so the query tells me if "Boy" is free and not care if "John Boy" is taken.
I thought I was just getting my head around ES but maybe not, I was under the impression that the field (see index mapping below) keyword I could do a term search and get back the exact match?
Below I've included my Pojo and my ES index mapping. Please if anyone can help me....thanks for reading:
Search Method
...ANSWER
Answered 2021-Apr-02 at 01:04I think you shuld reconsider the type of query you are using. Try using a simple match on the .keyword field.
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