Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Performs an exact search on a query
- *
- * @param queries
- * @return ArrayList of QueryResult objects
- */
- private List<QueryResult> exactSearch(Collection<String> queries) {
- // Temporary Map to combine results
- HashMap<String, QueryResult> combinedResults = new HashMap<>();
- ArrayList<QueryResult> queryResults = new ArrayList<>();
- // Get and combine the results
- for(String searchTerm : queries) {
- if(index.containsKey(searchTerm)) {
- for(String location : this.index.get(searchTerm).keySet()) {
- if(combinedResults.containsKey(location)) {
- combinedResults.get(location)
- .updateMatchCount(searchTerm, location);
- }
- else {
- QueryResult result = new QueryResult(location);
- result.updateMatchCount(searchTerm, location);
- combinedResults.put(location, result);
- queryResults.add(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement