Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. /**
  2. * Performs an exact search on a query
  3. *
  4. * @param queries
  5. * @return ArrayList of QueryResult objects
  6. */
  7. private List<QueryResult> exactSearch(Collection<String> queries) {
  8. // Temporary Map to combine results
  9. HashMap<String, QueryResult> combinedResults = new HashMap<>();
  10. ArrayList<QueryResult> queryResults = new ArrayList<>();
  11.  
  12. // Get and combine the results
  13. for(String searchTerm : queries) {
  14. if(index.containsKey(searchTerm)) {
  15. for(String location : this.index.get(searchTerm).keySet()) {
  16. if(combinedResults.containsKey(location)) {
  17. combinedResults.get(location)
  18. .updateMatchCount(searchTerm, location);
  19. }
  20. else {
  21. QueryResult result = new QueryResult(location);
  22. result.updateMatchCount(searchTerm, location);
  23. combinedResults.put(location, result);
  24. queryResults.add(result);
  25. }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement