Skip to content

How to transfer CriteriaQuery to QueryBuilder #1765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fageiguanbing opened this issue Apr 8, 2021 · 6 comments
Closed

How to transfer CriteriaQuery to QueryBuilder #1765

fageiguanbing opened this issue Apr 8, 2021 · 6 comments
Labels
status: feedback-provided Feedback has been provided

Comments

@fageiguanbing
Copy link

There are some problems to use CriteriaQuery API.
Such as nested query.

So, I found org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter#updateCriteria. Are there any other APIs for me to use?

Thanks!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 8, 2021
@sothawo sothawo added status: waiting-for-feedback We need additional information before we can continue and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 8, 2021
@sothawo
Copy link
Collaborator

sothawo commented Apr 8, 2021

What problems? We recently had some fixes for building (nested) queries for entities containing object or nested properties (#1753, #1758 and #1768)

There is no method to convert a CriteriaQuery - or any other Query implementation to a QueryBuilder, why should there be one?

@spring-projects-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Apr 15, 2021
@fageiguanbing
Copy link
Author

What problems? We recently had some fixes for building (nested) queries for entities containing object or nested properties (#1753, #1758 and #1768)

There is no method to convert a CriteriaQuery - or any other Query implementation to a QueryBuilder, why should there be one?

Thanks for your reply.

I got the solution of the nested query from #1753.

But how do I create a nested sort? I used org.springframework.data.domain.PageRequest to try to solve this problem but only creates a simple sort.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue labels Apr 19, 2021
@sothawo
Copy link
Collaborator

sothawo commented Apr 19, 2021

Nested sorts are not yet supported by Spring Data Elasticsearch. Please create a new issue for this.

@sothawo sothawo added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Apr 19, 2021
@fageiguanbing
Copy link
Author

OK, I will.

That's why I asked about the issue. In the future, Elasticsearch will be updated with many new APIs, but Spring-Data-Elasticsearch was not upgraded in time, if I can get QueryBuilder(or SourceBuilder), this will have better applicability.

Some scenarios can be implemented with Spring-Data-Elasticsearch, and some unsupported scenarios can be implemented with QueryBuilder.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Apr 20, 2021
@sothawo
Copy link
Collaborator

sothawo commented Apr 20, 2021

There are NativeSearchQueryand NativeSearchQueryBuilder where you can set query, filter and sort by using the original Elasticsearch query and sort builder and then create a Query that can be given to ElasticsearchOperations - for all those cases where CriteriaQueryor StringQuery are not enough.

@sothawo sothawo closed this as completed Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: feedback-provided Feedback has been provided
Projects
None yet
Development

No branches or pull requests

3 participants