i have two indices employee and organisation, both are linked via a common attribute organisationId. i want to do a search where searchString will be matched with EmpName, EmpDesignation and organisationName, and search should return me the employee object.
- searchString "james", result should return the employee object from employee index having name as james.
- searchString "developer", result should return the employee objects from employee index who are developer.
- searchString "microsoft", result should return the organisationId of microsoft from organisation index which will be used to search all employee objects from employee index who belong to microsoft.(Here i need a join like operation).
SearchRequest searchRequest = new SearchRequest("indexA","indexB"); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); Map<String,Float> fields = new HashMap<String, Float>(); fields.put("column1_From_IndexA", 0.0F); fields.put("column2_From_IndexA", 0.0F); fields.put("column1_From_IndexB", 0.0F); QueryStringQueryBuilder builder = QueryBuilders.queryStringQuery("searchString").fields(fields); searchSourceBuilder.query(builder); searchRequest.source(searchSourceBuilder); SearchResponse response = client.search(searchRequest, RequestOptions.DEFAULT);
this code snippet return the combination of everything which is messy.
please suggest how to achieve this.
Thanks in advance.