Interface AnnotationSearchRankingStrategy
- All Known Implementing Classes:
CommonalityRankingStrategy, CompositeRankingStrategy, LuceneOrderRankingStrategy, TokenCoverageRankingStrategy, UsageWeightedRankingStrategy
Implementations get the original query string, the Lucene-ordered hits (original index = list position), and a per-URI usage-count map (number of distinct experiments that reference each URI). They must return a new list — same hits, possibly re-ordered — and must be stable and side-effect free. They must not mutate the input list.
See handoffs/RECCE_ANNOTATION_SEARCH_RANKING.md for the motivating design.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetName()Short stable name used as the value of the?rank=query parameter and as the bean name in the strategy registry.rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri) Re-orderrawHitsaccording to this strategy.default List<CharacteristicValueObject> rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri, Map<String, Integer> stringPriorByUri) Re-orderrawHitswith the per-string corpus prior available in addition to the usage counts.default List<CharacteristicValueObject> rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri, Map<String, Integer> stringPriorByUri, Map<String, String> matchedTextByUri) Re-orderrawHitswith the per-URI matched text available in addition to the counts.default booleanWhether this strategy reads thestringPriorByUrimap duringrank(String, List, Map).default booleanWhether this strategy reads theusageCountsByUrimap duringrank(String, List, Map).
-
Method Details
-
rank
List<CharacteristicValueObject> rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri) Re-orderrawHitsaccording to this strategy.- Parameters:
originalQuery- the original query string the user typed; whitespace-tokenised and lowercased by token-coverage strategies; may be blank.rawHits- the Lucene-ordered hits; index in this list is the "original rank" used by rank-aware strategies. Must not be mutated.usageCountsByUri- per-URI count of distinct experiments referencing the URI; may be empty.- Returns:
- a new list of the same hits in the desired display order.
-
rank
default List<CharacteristicValueObject> rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri, Map<String, Integer> stringPriorByUri) Re-orderrawHitswith the per-string corpus prior available in addition to the usage counts.Callers should invoke this overload; it defaults to the three-argument
rank(String, List, Map)so a strategy that has no use for the prior needs no changes. Only strategies that returntruefromrequiresStringPrior()receive a populated map.- Parameters:
stringPriorByUri- per-URI count of distinct experiments on which a prior curator wrote the query string itself as the annotation's original value; may be empty. Distinct fromusageCountsByUri, which counts every use of the URI regardless of what was written.
-
rank
default List<CharacteristicValueObject> rank(String originalQuery, List<CharacteristicValueObject> rawHits, Map<String, Integer> usageCountsByUri, Map<String, Integer> stringPriorByUri, Map<String, String> matchedTextByUri) Re-orderrawHitswith the per-URI matched text available in addition to the counts.Callers should invoke this overload; it defaults to the four-argument
rank(String, List, Map)so a strategy with no use for the matched text needs no changes.This exists because a coverage-scoring strategy that reads only
hit.getValue()scores zero for a hit that matched through a synonym — its label shares nothing with the query, which is the entire reason the synonym exists.dmsofinding dimethyl sulfoxide worked only by accident, both candidates scoring 0 coverage so usage broke the tie. The attribution pass already computes this string for the whole candidate set before truncation, so passing it costs nothing.- Parameters:
matchedTextByUri- per-URI text that actually matched the query — a preferred label, a declared synonym, or an alternate label — as reported bymatchedText; may be empty, and may omit URIs whose attribution could not be resolved.
-
getName
String getName()Short stable name used as the value of the?rank=query parameter and as the bean name in the strategy registry. Lowercase, single word. -
requiresUsageCounts
default boolean requiresUsageCounts()Whether this strategy reads theusageCountsByUrimap duringrank(String, List, Map). Defaultfalse; strategies that do (usage, composite) override totrue. Whenfalse, callers can skip the count lookup entirely for the candidate set and only compute counts for the truncated top-N display payload — turning the dominant cost on the typeahead path (~2-3s for a 400-1000 candidate IN-clause against the characteristic-by-uri index) into a much cheaper top-N query. -
requiresStringPrior
default boolean requiresStringPrior()Whether this strategy reads thestringPriorByUrimap duringrank(String, List, Map). Defaultfalse;CommonalityRankingStrategyoverrides totrue.Kept separate from
requiresUsageCounts()rather than folded into one "needs corpus stats" flag because the two queries have different costs and answer different questions: a strategy that wants the per-string prior should not be made to pay for the usage scan, or the other way round.
-