Repository navigation
Exclude acronyms from multisearch candidate retrieval - #600
Merged
Merged
Conversation
Query PHRASE/COMMON/FUZZY/HEURISTICS against nested affiliation_match.names (acronym-free at index time) instead of names.value.norm. Restore v2 acronyms keyword field for the ACRONYM matching type. Refs ror-community/ror-roadmap#345 Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>
cursor
Bot
force-pushed
the
features/exclude-acronyms-multisearch
branch
from
October 1, 2026 21:21
e8def72 to
e2bea58
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Acronym matching now fails when an acronym appears within a longer affiliation string.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Retargets multisearch candidate retrieval to acronym-free affiliation names while preserving explicit acronym matching.
Changes:
- Adds nested affiliation-name query helpers.
- Restores and populates the dedicated acronym index field.
- Adds unit and integration coverage.
| File | Description |
|---|---|
rorapi/common/es_utils.py |
Adds nested affiliation-name queries. |
rorapi/common/matching.py |
Uses the new query helpers. |
rorapi/common/index_helpers.py |
Populates indexed acronyms. |
rorapi/v2/index_template_es7.json |
Maps the acronym keyword field. |
rorapi/tests/tests_unit/tests_es_utils_v2.py |
Tests query structures. |
rorapi/tests/tests_unit/tests_index_helpers.py |
Tests acronym enrichment. |
rorapi/tests/tests_integration/tests_matching_v2.py |
Covers the UCLA regression. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| q.add_fuzzy_query_affiliation_names(normalized) | ||
| elif matching_type == MATCHING_TYPE_ACRONYM: | ||
| q.add_match_query(normalize(text)) | ||
| q.add_match_query(normalized) |
adambuttrick
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Purpose
Fix ror-community/ror-roadmap#345: multisearch PHRASE/COMMON/FUZZY/HEURISTICS must not retrieve organizations via acronym name values (e.g.
UCLAchoosinghttps://ror.org/03qgg3111because its acronym is UCLA).Approach
Single search already queries nested
affiliation_match.names, populated without acronyms at index time. Multisearch incorrectly used flatnames.value.norm, which includes acronyms becausenamesis not nested in the v2 mapping.Retarget multisearch text strategies to the same acronym-free nested field. Restore a top-level
acronymskeyword field for the intentionalMATCHING_TYPE_ACRONYMpath (add_match_query).Key Modifications
rorapi/common/es_utils.py:add_phrase_query_affiliation_names,add_common_query_affiliation_names,add_fuzzy_query_affiliation_names(nested onaffiliation_match.names).rorapi/common/matching.py: PHRASE/COMMON/FUZZY/HEURISTICS use those helpers instead ofnames.value.norm.rorapi/v2/index_template_es7.json:acronymskeyword withfolding_normalizer.rorapi/common/index_helpers.py: populateacronymsinenrich_org_for_index.UCLAmultisearch does not choose03qgg3111.Important Technical Details
createindex/setupor dump) soacronymsexists on all documents.affiliation_matchis already populated; nested multisearch queries work once data is present. Until reindex, ACRONYM matching may not hit the new field.namesobject; advanced search onnames.valueunchanged.get_scoreacronym boost unchanged for the ACRONYM path; wrong PHRASE candidates should no longer be retrieved via acronyms.Types of changes
Reviewer, please remember our guidelines:
Test plan
test-pr / testandflow-guardpass;ruffsoft-fails repo-wide withcontinue-on-error, unrelated)tests_es_utils_v2(nested affiliation query shapes),tests_index_helpers(acronyms enrich)?affiliation=UCLA&multisearchmust not returnhttps://ror.org/03qgg3111aschosen=True; integration test intests_matching_v2.pywhen run against a current index