Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for wrong name matches when rank is filled #228

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1183,16 +1183,11 @@ private List<NameSearchResult> performSearch(List<Value> compulsoryValues, RankT
}

if (rank != null) {
int lower = rank.getId();
int upper = rank.getId() >= RankType.SPECIES.getId() ? 9999 : rank.getId();
BooleanQuery.Builder rankBuilder = new BooleanQuery.Builder();
rankBuilder.add(NameIndexField.RANK_ID.searchRange(lower, upper), BooleanClause.Occur.SHOULD);
//cater for the situation where the search term could be a synonym that does not have a rank
// also ALA added concepts do NOT have ranks.
rankBuilder.add(NameIndexField.iS_SYNONYM.search("T"), BooleanClause.Occur.SHOULD);
rankBuilder.add(NameIndexField.ALA.search("T"), BooleanClause.Occur.SHOULD);
BooleanQuery.Builder rankBuilder = new BooleanQuery.Builder();
rankBuilder.add(NameIndexField.RANK.search(rank.getRank()), BooleanClause.Occur.MUST);
builder.add(rankBuilder.build(), BooleanClause.Occur.MUST);
}

if (cl != null) {
this.appendLuceneQuery(cl, builder, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2205,4 +2205,20 @@ public void testPreferredVernacular2() throws Exception {
assertEquals("Orange Roughy", metrics.getResult().getVernacularName());
}

@Test
// https://github.com/AtlasOfLivingAustralia/Taxonomic-Issues-Register_new/issues/161
public void testSearchEucalyptus() throws Exception {
LinnaeanRankClassification cl = new LinnaeanRankClassification();
cl.setGenus("Eucalyptus");
cl.setSpecificEpithet("`hammonds rd'");
cl.setScientificName("Eucalyptus `hammonds rd'");
cl.setSubspecies("Eucalyptus pauciflora subsp. debeuzevillei");
cl.setRank("species");

MetricsResultDTO metrics = searcher.searchForRecordMetrics(cl, true);

assertNotNull(metrics);
// Without patching it returns "Eucalyptus de beuzevillei"
assertEquals("Eucalyptus", metrics.getResult().getRankClassification().getScientificName());
}
}