@@ -50,15 +50,7 @@ public class ElasticsearchService {
5050 @ Value ("${elasticsearch.enabled}" )
5151 private boolean esEnabled ;
5252
53- /**
54- * Universal search with optional user location for ranking
55- */
56-
57- /**
58- * Advanced search with multiple criteria
59- * Searches by firstName, lastName, gender, DOB, address fields, etc.
60- */
61-
53+
6254/**
6355 * Universal search with score-based filtering and location ranking
6456 * Only returns records that actually match the query (not all 10000)
@@ -155,10 +147,10 @@ public List<Map<String, Object>> universalSearch(String query, Integer userId) {
155147 .boostMode (FunctionBoostMode .Multiply )
156148 )
157149 )
158- .minScore (minScore ) // KEY: Only return results above minimum score
159- .size (500 ) // Reasonable limit - returns only matches up to 500
150+ .minScore (minScore )
151+ .size (500 )
160152 .sort (so -> so
161- .score (sc -> sc .order (SortOrder .Desc )) // Sort by relevance score
153+ .score (sc -> sc .order (SortOrder .Desc ))
162154 )
163155 , BeneficiariesESDTO .class );
164156
@@ -176,7 +168,7 @@ public List<Map<String, Object>> universalSearch(String query, Integer userId) {
176168 }
177169 Map <String , Object > result = mapESResultToExpectedFormat (hit .source ());
178170 if (result != null ) {
179- result .put ("_score" , hit .score ()); // Include score for debugging
171+ result .put ("_score" , hit .score ());
180172 }
181173 return result ;
182174 })
@@ -421,8 +413,8 @@ public List<Map<String, Object>> advancedSearch(
421413 .boostMode (FunctionBoostMode .Multiply )
422414 )
423415 )
424- .minScore (2.0 ) // Only return good matches
425- .size (500 ) // Reasonable limit
416+ .minScore (2.0 )
417+ .size (500 )
426418 .sort (so -> so
427419 .score (sc -> sc .order (SortOrder .Desc ))
428420 )
@@ -615,6 +607,7 @@ private Map<String, Object> mapESResultToExpectedFormat(BeneficiariesESDTO esDat
615607 result .put ("genderID" , esData .getGenderID ());
616608 result .put ("genderName" , esData .getGenderName ());
617609 result .put ("dob" , esData .getDOB ());
610+ result .put ("dOB" , esData .getDOB ());
618611 result .put ("age" , esData .getAge ());
619612 result .put ("fatherName" , esData .getFatherName () != null ? esData .getFatherName () : "" );
620613 result .put ("spouseName" , esData .getSpouseName () != null ? esData .getSpouseName () : "" );
0 commit comments