Commit c6b4dc19 authored by tammam.alsoleman's avatar tammam.alsoleman

Edit to return the result to the front

parent 1660c00d
......@@ -46,10 +46,9 @@ public class SearchClient {
/**
* Orchestrates the 2-Phase Distributed Search.
*/
public void performSearch(List<String> terms, List<String> allFiles) {
public List<SearchResponse.DocumentResult> performSearch(List<String> terms, List<String> allFiles) {
if (stubs.isEmpty()) {
System.out.println("No workers available.");
return;
return Collections.emptyList();
}
// Phase 1: Aggregate Global Counts
......@@ -103,11 +102,8 @@ public class SearchClient {
currentFileIndex += count;
}
// --- Sort and Show Top 10 ---
// --- return the sorted list ---
finalResults.sort((a, b) -> Double.compare(b.getScore(), a.getScore()));
System.out.println("\n--- Search Results ---");
for (int i = 0; i < Math.min(10, finalResults.size()); i++) {
System.out.println((i + 1) + ". " + finalResults.get(i).getDocumentName() + " (Score: " + finalResults.get(i).getScore() + ")");
}
return finalResults;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment