Source:
<code>public ResponseEntity<LinkedHashSet<TypeaheadSearchResp>> searchTypeAheadGet( @ApiParam(value = "The search query, it could be hugoSymbol, entrezGeneId or variant.", required = true) @RequestParam(value = "query") String query, @ApiParam(value = "The limit of returned result.") @RequestParam(value = "limit", defaultValue = "5", required = false) Integer limit) { LinkedHashSet<TypeaheadSearchResp> result = new LinkedHashSet<>(); if (limit == null) { limit = TYPEAHEAD_RETURN_LIMIT; } if (query != null) { List<String> keywords = Arrays.asList(query.trim().split("\\s+")); if (keywords.size() == 1) { result.addAll(convertGene(GeneUtils.searchGene(keywords.get(0), false), keywords.get(0))); result.addAll(convertVariant(AlterationUtils.lookupVariant(keywords.get(0), false, AlterationUtils.getAllAlterations()), keywords.get(0))); } else if (keywords.size() == 2) { Map<String, Set<Gene>> map = new HashedMap(); for (String keyword : keywords) { map.put(keyword, GeneUtils.searchGene(keyword, true)); } <START> result.addAll(getMatch(map, keywords, true)); <END> result.addAll(getMatch(map, keywords, false)); if (result.size() == 0) { for (Map.Entry<String, Set<Gene>> entry : map.entrySet()) { if (entry.getValue().size() > 0) { for (Gene gene : entry.getValue()) { for (String keyword : keywords) { if (!keyword.equals(entry.getKey())) { Alteration alteration = AlterationUtils.getAlteration(gene.getHugoSymbol(), keyword, null, null, null, null); AlterationUtils.annotateAlteration(alteration, keyword); TypeaheadSearchResp typeaheadSearchResp = newTypeaheadVariant(alteration); typeaheadSearchResp.setVariantExist(false); result.add(typeaheadSearchResp); } } } } } } } } return new ResponseEntity<>(getLimit(result, limit), HttpStatus.OK); }</code><technical_language>do need getMatch twice? exact match result include exact match result</technical_language>

Target:
public ResponseEntity<LinkedHashSet<TypeaheadSearchResp>> searchTypeAheadGet( @ApiParam(value = "The search query, it could be hugoSymbol, entrezGeneId or variant.", required = true) @RequestParam(value = "query") String query, @ApiParam(value = "The limit of returned result.") @RequestParam(value = "limit", defaultValue = "5", required = false) Integer limit) { LinkedHashSet<TypeaheadSearchResp> result = new LinkedHashSet<>(); if (limit == null) { limit = TYPEAHEAD_RETURN_LIMIT; } if (query != null) { List<String> keywords = Arrays.asList(query.trim().split("\\s+")); if (keywords.size() == 1) { result.addAll(convertGene(GeneUtils.searchGene(keywords.get(0), false), keywords.get(0))); result.addAll(convertVariant(AlterationUtils.lookupVariant(keywords.get(0), false, AlterationUtils.getAllAlterations()), keywords.get(0))); } else { Map<String, Set<Gene>> map = new HashedMap(); for (String keyword : keywords) { map.put(keyword, GeneUtils.searchGene(keyword, true)); } result.addAll(getMatch(map, keywords, false)); if (result.size() == 0) { for (Map.Entry<String, Set<Gene>> entry : map.entrySet()) { if (entry.getValue().size() > 0) { for (Gene gene : entry.getValue()) { for (String keyword : keywords) { if (!keyword.equals(entry.getKey())) { Alteration alteration = AlterationUtils.getAlteration(gene.getHugoSymbol(), keyword, null, null, null, null); AlterationUtils.annotateAlteration(alteration, keyword); TypeaheadSearchResp typeaheadSearchResp = newTypeaheadVariant(alteration); typeaheadSearchResp.setVariantExist(false); if (typeaheadSearchResp.getOncogenicity() != null && !typeaheadSearchResp.getOncogenicity().isEmpty()) { result.add(typeaheadSearchResp); } } } } } } } } } return new ResponseEntity<>(getLimit(result, limit), HttpStatus.OK); }