question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to convert CriteriaQuery and NativeSearchQuery to raw ES query JSON?

See original GitHub issue

My 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:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
sothawocommented, May 13, 2021

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.

0reactions
ToffeeLucommented, May 13, 2021

So what spring did is CriteriaQuery -> SearchRequest -> ES lib -> ES service

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found