How to read a specific data from elasticsearch

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.

Thanks.

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.

@jaddison
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("updateDetails.properties.name", name);
    QueryBuilder searchDob = QueryBuilders.matchQuery("updateDetails.properties.dob", dob);
    QueryBuilder searchGender = QueryBuilders.matchQuery("updateDetails.properties.gender", gender);
BoolQueryBuilder findUserDetails = QueryBuilders.boolQuery().must(searchPpo).must(searchName).must(searchDob)
					.must(searchGender);
    searchSourceBuilder.query(findUserDetails);
    searchRequest.source(searchSourceBuilder);
	SearchResponse responseWithAllParam = client.search(searchRequest);

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.
Thanks
Is there some way that we can remove the hardcoded value of fieldName?

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