Skip to content

Fix advanced search for spaced external IDs and clarify v1 FundRef paths - #596

Merged
jrhoads merged 1 commit into
devfrom
features/advanced-search-external-ids
Oct 1, 2026
Merged

jrhoads merged 1 commit into
devfrom
features/advanced-search-external-ids

Conversation

@jrhoads

@jrhoads jrhoads commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Purpose

Fix ror-community/ror-roadmap#71 so unquoted ISNI (and other space-containing) values work in query.advanced, and improve the error for legacy v1 FundRef-style paths from ror-community/ror-roadmap#70 without adding field aliases.

Approach

query.advanced builds an Elasticsearch query_string with default_operator: and. Unquoted whitespace splits the value into multiple terms, so a keyword like 0000 0001 2375 2908 never matches external_ids.all. Quoting already worked; we now auto-quote those values in Python before the query is built.

Roadmap #70’s original Fundref template misspelling is gone under schema v2 (external_ids is an array of {type, all, preferred}). Old paths like external_ids.FundRef.all remain illegal; the validator now explains the v2 fields to use instead.

Key Modifications

  • rorapi/common/queries.py: quote_spaced_external_id_values() for external_ids.all / external_ids.preferred; apply it in build_search_query after NFC normalization. Clearer illegal-field message when the path looks like external_ids.<Type>.(all|preferred).
  • Unit tests for quoting and the legacy-path hint; integration tests for unquoted ISNI, v2 FundRef syntax, and the legacy error hint.

Important Technical Details

  • Only external_ids.all and external_ids.preferred are auto-quoted (values stop at AND/OR/NOT, ), or end of string). Already-quoted values and values without whitespace are unchanged.
  • We do not strip spaces or accept unspaced ISNIs (0000000123752908); those are not indexed.
  • No legacy aliases for external_ids.FundRef.all — correct v2 forms are external_ids.all:100000908 or external_ids.type:fundref AND external_ids.all:100000908.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

Test plan

  • CI (test-pr / test and flow-guard pass; ruff soft-fails repo-wide with continue-on-error, unrelated)
  • Unit tests for quoting helper, advanced-query quoting, and legacy FundRef path hint
  • Integration: unquoted external_ids.all:0000 0001 2375 2908 returns https://ror.org/019496w77 (same as quoted); v2 FundRef query returns https://ror.org/02g8xhs57; legacy external_ids.FundRef.all error includes the v2 hint
Open in Web Open in Cursor 

Auto-quote unquoted external_ids.all / preferred values that contain
whitespace so ISNI-style IDs match as a single keyword (ror-roadmap#71).
When a legacy v1 path like external_ids.FundRef.all is used, include a
hint pointing at the v2 fields (ror-roadmap#70).

Refs ror-community/ror-roadmap#70, ror-community/ror-roadmap#71

Co-authored-by: Joseph Rhoads <jrhoads@users.noreply.github.com>
@jrhoads
jrhoads merged commit cee31f0 into dev Oct 1, 2026
2 of 3 checks passed
@jrhoads
jrhoads deleted the features/advanced-search-external-ids branch October 1, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants