Skip to content

Commit

Permalink
Fix ID search
Browse files Browse the repository at this point in the history
  • Loading branch information
yihangx committed Aug 22, 2024
1 parent eb1904c commit 12e2360
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ private List<WPPathway> filterPathways(List<WPPathway> pathways, String query, S
for (WPPathway pathway : pathways) {
boolean matches = false;

// ID match with exact case-insensitive comparison
if (pathway.getId().equalsIgnoreCase(query)) {
filteredResults.clear(); // Clear any previous results because we only want this exact match
filteredResults.add(pathway);
return filteredResults; // Return immediately as we have found an exact ID match
}

if (isExactMatch) {
// Exact match search: match only if the name field matches the exact phrase
matches = pathway.getName().equalsIgnoreCase(lowerQuery);
Expand All @@ -198,7 +205,7 @@ private List<WPPathway> filterPathways(List<WPPathway> pathways, String query, S
pathway.getAuthors().toLowerCase().contains(lowerQuery) ||
pathway.getAnnotations().toLowerCase().contains(lowerQuery) ||
pathway.getCitedIn().toLowerCase().contains(lowerQuery);

// Check datanodes for all query terms
boolean allTermsMatch = true;
for (String term : queryTerms) {
Expand All @@ -219,15 +226,11 @@ private List<WPPathway> filterPathways(List<WPPathway> pathways, String query, S
}
}

// Filter again to ensure only exact id match if query is id
if (query.toLowerCase().startsWith("wp")) {
filteredResults.removeIf(p -> !p.getId().equalsIgnoreCase(query));
}

return filteredResults;
}





public ResultTask<WPPathway> pathwayInfoTask(final String id) {
Expand Down

0 comments on commit 12e2360

Please sign in to comment.