How to read a specific data from elasticsearch

(Vivek Ranjan) #1

What is the efficient way to read a specific data from elastic search. For Example we have 3 field namely, name, dob and gender and I want to get the value of each of them so that I can compare it with newly given values for these three. I am using Java to do the same and I am using ES6.3.0. Kindly suggest me a way to achieve the same.

I have tried searching it online but not getting any clue.


(James Addison) #2

What have you tried so far? Please paste in well formatted/indented code samples, index settings/mappings, sample documents, and any queries you've tried.

Based on your description here, it seems like it should be straightforward to get data out so you can compare it to values in your Java code.

(Vivek Ranjan) #3

Hi thanks for reverting back.

here is the query which i have wrote to get the output but it seems I have hard coded the field values here.

    QueryBuilder searchName = QueryBuilders.matchQuery("", name);
    QueryBuilder searchDob = QueryBuilders.matchQuery("", dob);
    QueryBuilder searchGender = QueryBuilders.matchQuery("", gender);
BoolQueryBuilder findUserDetails = QueryBuilders.boolQuery().must(searchPpo).must(searchName).must(searchDob)
	SearchResponse responseWithAllParam =;

Here if you see in first line of the code I have hardcoded the value with "updateDetails", "properties" and "name". If in future some one will change the field name itself then we will not be able to fetch the data and will get 404 error.
Is there some way that we can remove the hardcoded value of fieldName?

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.