spring-projects / spring-data-elasticsearch

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.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.9k stars 1.33k forks source link

Unable to covert my existing NativeSearchQueryBuilder into NativeQueryBuilder #2962

Closed naidusana closed 1 month ago

naidusana commented 1 month ago

How can I convert below code using NativeQuery?

           BoolQueryBuilder bQB = QueryBuilders.boolQuery();
    bQB.must(QueryBuilders.termQuery("INDEX_NAME", "testindex"));
    bQB.must(QueryBuilders.termsQuery("STATUS", "INPROGRESS", "PUBLISHED"));
    bQB.must(QueryBuilders.termQuery("DATA_LOAD_TYPE", "INCR"));
    NativeSearchQueryBuilder nsqb = new NativeSearchQueryBuilder()
        .withQuery(bQB);
sothawo commented 1 month ago

Check the Elasticsearch documentation for the use of the Java client, these are the queries passed in to NativeQueryBuilder. Elasticsearch modeled their Java API along the REST API, so the best probably is to build your query like you'd be sending it via REST and then transfer this to the Java code.