How to convert CriteriaQuery and NativeSearchQuery to raw ES query JSON?
See original GitHub issueMy requirement is serviceA->serviceB->ES.
service-A a building a query by the JSON of CriteriaQuery or NativeSearchQuery
and send this query request by HTTP to service-B, then service-B will query ElasticSearch by the received request.
So what I want is service-A build query by CriteriaQuery or NativeSearchQuery
which is more user-friendly than raw ES query.
On service-B, we receive the request then query ES by StringQuery
I only find this but it doesn’t help. https://discuss.elastic.co/t/convert-searchsourcebuilder-to-json/156118
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Elasticsearch Queries with Spring Data - Baeldung
Learn how to use the various query types offered by Elasticsearch and understand field analyzers and their impact on search results.
Read more >How to enable query logging in Spring-data-elasticsearch
After digging through the spring data code i found this helpful little logger called "tracer" (name not very unique).
Read more >How to transfer CriteriaQuery to QueryBuilder #1765 - GitHub
There are some problems to use CriteriaQuery API. Such as nested query. So, I found org.springframework.data.elasticsearch.core.convert.
Read more >Pass raw json string query to Elastic Search using java
I have got the data from Elasticsearch index by using the below code: SearchRequest request = new SearchRequest("football_sum_csv").scroll(new ...
Read more >How to get the SQL query from JPQL or JPA Criteria
While most developers know it for the extra custom types, like JSON, ARRAY, Interval, IP, the Hibernate Types project offers many other ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We won’t expose ES raw queries, even if we would build them which we don’t. Spring Data is about hiding away store specific implementation details, not exposing them.
So what spring did is
CriteriaQuery
->SearchRequest
-> ES lib -> ES serviceWe decide to create a customized simple query API contract for service A to use, and we convert it to
NativeSearchQuery
then send it to ES through Spring lib.Thanks again. If I found more thing on serialization or deserialization about ES raw query, I will discuss with you and may contribute for converting in future.