Repository navigation
OpenConceptLab/ocl_online#452 | A reference's search options apply to its search again, in either spelling - #1089
Conversation
… its search again, in either spelling A reference made from a pasted search URL carries that search's options (excludeWildcard, excludeFuzzy, includeSearchMeta, searchMapCodes, exactMatch, verbose) in its filter. Since the change for ocl_issues#2201 (camelCase filter properties such as conceptClass), the camelCase options were matched as fields the index doesn't have, so such a reference selected nothing. References saved since then store the options snake_cased, which were matched the same way. - The options are recognised in either spelling before the camelCase switch, and never matched as fields. conceptClass and the other camelCase properties still work. - They're applied to `q` as the search API applies them: exact matches, or wildcard matches too when excludeWildcard is false, or fuzzy matches too when excludeFuzzy is false; searchMapCodes false leaves out map codes. A reference still matches exactly unless its filter says otherwise. - A filter of options alone selects everything the reference's system or value set has, as the search with no `q` lists it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
…kip the index; last value wins; exact spellings; fuzzy text lowercased - A filter of search options alone selects what the reference's system or value set has without asking the search index, so a member not indexed yet still counts, and a large version isn't read 500 ids at a time. - A repeated option (a pasted URL's excludeFuzzy=true&excludeFuzzy=false) takes its last value, as the search API reads it. - Options are recognised as the search API spells them or snake_cased, nothing looser. - Fuzzy matching gets the lowercased text, as the search API sends it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
…elect what no filter selects; the text read as the search API reads it - A filter of search options alone returns the reference's queryset as a reference with no filter does, whatever the resource-versions toggle. - A `q` value is trimmed and its quotes dropped, as the search API reads its text, and the wildcard clause gets the search API's form of it. (No production reference's `q` has quotes or surrounding spaces.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
… text as it is; only wildcard and fuzzy normalise it A reference whose filter has only `q` matches exactly as before, a literal quote included (a mapped code such as AB'12). Wildcard and fuzzy matches, which only a search option turns on, read the text as the search API does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
… tests, an early return - has_param_in_filter returns early for a name that isn't a search option. - The spelling cases live in get_filter_clause_property's table; the release test is a case of the no-filter comparison, which now also names the source without a version. - The repeated-value and snake_case cases stay in the end-to-end tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
…search URL reads its text as that search does A filter with search options came from a search URL, so its `q` is read as the search API reads its text (trimmed, quotes dropped) for exact matches too. A `q` alone is still matched as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
…ly exactly as without them A reference's search options (excludeWildcard, excludeFuzzy, includeSearchMeta, searchMapCodes, exactMatch, verbose) behave the same with FHIR's rules on and off: master's fix for them (#1089), and the database path uses it. - Both spellings, camelCase and snake_case, are options, through one definition (get_search_modifier); the database path's own set is gone. - They apply to `q` as the search API applies them, through the search both paths share. - A filter of options alone selects what a reference with no filter selects, with FHIR's rules on as off. - An option or a pasted parameter with an op OCL can't apply is refused under FHIR's rules too, as without them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWzjyD2kDtz5SyuRMw
snyaggarwal
left a comment
There was a problem hiding this comment.
Review (Sunny): verdict needs changes (request changes)
The fix itself reads right. Both spellings are now search options and never fields, q matching follows the search API (exact, OR wildcard, OR fuzzy), and a q alone matches as before. My one block is about when it ships, not about the code.
| # | Severity | Where | Finding |
|---|---|---|---|
| 1 | blocking | core/collections/models.py:1320 |
Changes existing expansions with no switch. Merging puts it in the next release. |
| 2 | should fix | core/collections/models.py:1226-1228 |
"As that search with no q lists it" is not true for retired content. The data-step numbers should split it out. |
| 3 | should fix | core/collections/models.py:1320 |
A cascade on an options-only reference now walks every concept in the version. Check the 25 before the data step. |
| 4 | nit | core/collections/translators.py:85-101 (not in the diff) |
The reference's English text still reads the options as property matches ("having excludeWildcard equal to ..."). |
Does this change behaviour for existing API users and expansions? Yes. It is a behaviour change, not a switched one.
- Where it shows: the next time a version's references are evaluated again. That happens on a rebuild (
dry_run_rebuildshows the change first) or when a new collection version is created from HEAD and its expansion is seeded. The reference's stored results (reference.concepts/mappings) are written back then too, so its resolved resources jump with it. - Who sees what: using the author's counts, 25 collection versions (14 active HEADs) go from nothing to up to their whole target version. The largest gains about 286k concepts and 380k mappings. 61 versions keep members that a rebuild on master today would drop.
qmatching stays exact for every production reference with options, because all of them set the three options totrue. - Health: no new reason codes. These references were not
filter_not_appliedbefore and are not now. Under the toggle, unversioned references still get the searched version's resource versions: options alone return the same queryset as no filter, which the toggle test covers. - What it needs: a decision and a data step for the 25 (#797), as the PR says, before this reaches production. Until this ships, avoid rebuilding the 61 on master.
Credit: the author already reported the release mapped-codes gap, the blank repeated option, q="", and the hand-written quoted q with a display-only option. I don't repeat them.
What I could not verify: I made no production or staging queries, so I did not recheck the counts. I did not check how much of the gain is retired content or how many of the 25 references cascade (findings 2 and 3). I did not trace whether adding an unrelated reference to an autoexpand HEAD re-evaluates existing references. I relied on CI for tests (pylint and tests pass) and did not run them myself. There is no test of an options-only reference through Expansion.add_references or a rebuild, only at the get_concepts/get_mappings level.
| if has_unapplied: | ||
| return resource_klass.objects.none() # an entry it can't apply never leaves the others to widen it | ||
| if not is_searched: | ||
| return queryset # search options alone: all it has, as with no filter, indexed or not |
There was a problem hiding this comment.
blocking. This line is the behaviour change for existing expansions. 25 collection versions (14 active HEADs) go from nothing to their whole target version on their next rebuild, or when a new collection version is seeded. Nothing gates it. The PR says "don't deploy until the data step is decided", but master ships in the next release (2.3.279 is already bumped), so once this merges, nothing holds it back.
Fix: either keep this unmerged until the #797 data step is decided, or put this path behind a toggle that stays off until then, like the per-evaluation switch phase B already uses. Either is fine by me. Say which.
There was a problem hiding this comment.
Behind a toggle, your second option, in e92e022 and cd0db49.
REFERENCE_SEARCH_OPTIONS_TOGGLEis a new row intoggles.json(pk 14), off in every environment, so merging changes nothing.- With it off, master's code runs.
get_filter_clause_property,get_allowed_filter_propertiesandget_filter_errorsare master's again, so the options are matched as fields.- A
qis matched by master's own code (_get_search_criterion_as_before), so even the query sent is the same. - This line (options alone selecting the version) runs only with it on.
- The toggle is read only for a filter that has a search option.
- Tests: master's behaviour with it off, and the restored one with it on. Also an options-only reference added to an expansion and rebuilt, with it off, on and off again. I ran the toggle-off checks against master's own code too, with the same results. They fail on the previous head, 0be05b8.
- Still true: rebuilding the 61 collection versions on master empties them, with the toggle off too. The toggle goes on only after the data step for the 25 is decided (OpenConceptLab/ocl_online#797), so its date waits for that.
| criterion = _criterion if criterion is None else criterion | _criterion | ||
| return criterion | ||
|
|
||
| # a pasted search URL's search options: they change how `q` matches, or what each result shows, never which |
There was a problem hiding this comment.
should fix. "As that search with no q lists it" is not accurate. The search API leaves out retired concepts and mappings unless includeRetired is set. This path returns them, and the new test expects that (everything includes retired). A pasted /concepts/?excludeWildcard=true... URL showed the user only active concepts, but the reference adds the retired ones too. That is consistent with what the 61 pre-regression versions hold today, so I wouldn't change the behaviour here.
Fix: reword the comment (and the PR text) to "as a reference with no filter selects it, retired included". Split the retired part out of the 25 versions' expected gain, so the #797 decision is made on the real numbers. An expansion's activeOnly still drops them.
There was a problem hiding this comment.
Kept as you suggest, after checking the history. Before e108607 (Jul 2025), these options were set aside, and a reference with no q selected every indexed concept or mapping of its version, retired ones included. The 61 older versions hold exactly that today.
- Reworded in e92e022: "selects what a reference with no filter selects, retired content included, as references did before Jul 2025". The PR body says the same. The expansion test checks that a retired concept is added.
- The 25, split (upper bounds): concepts up to 1,279,607 active + 124,177 retired, mappings up to 2,937,795 active + 387,813 retired. The Bump boto3 from 1.24.28 to 1.36.1 #797 list has them per collection version.
- One correction: the concept total is 1,403,784, not 1,428,958. Two of the 25 each have two concept references to the same version, which were counted twice.
There was a problem hiding this comment.
Fixed in e92e022. The comment and the PR body now say retired content is included, as before Jul 2025, and the expansion test adds a retired concept. Thanks for the active/retired split and the corrected total.
| is_searched = True | ||
| if has_unapplied: | ||
| return resource_klass.objects.none() # an entry it can't apply never leaves the others to widen it | ||
| if not is_searched: |
There was a problem hiding this comment.
should fix (check before the data step). Before this change, an options-only reference selected nothing, so its cascade never ran. Now get_concepts passes the whole version into _apply_cascade, which calls concept.cascade() once per concept. That is up to about 286k calls for the largest of the 25. A rebuild like that can take hours, and the FHIR ValueSet write path builds synchronously.
Fix: count how many of the 25 versions' references set cascade, and put that in the #797 data step. If any do, plan their rebuilds off-peak, or rebuild them through the async path.
There was a problem hiding this comment.
Counted and measured. It's about half an hour per rebuild for the largest, locally.
-
22 of the 25 cascade (
sourcetoconcepts, orsourcemappingsfor 2). Only 3 don't. If each is rebuilt once, that's 1,423,154cascade()calls. -
Local cost: 3.5 to 5.6 ms per call, depending on how many set and answer mappings the concepts have. On top of that,
_apply_cascadekeeps the concepts it has walked in a list, and checks each new one against it, so that part grows with the square of the count: 10 s for 60,000 concepts, 40 s for 120,000. -
Per rebuild: that's about 20 to 30 minutes for each of the three largest (252,212 to 286,477 concepts) and 4 to 6 minutes for each of the nine with 58,947. I couldn't measure production (EXPLAIN only), and its database is a network hop away, so expect it slower.
-
Not new in kind: an unfiltered
{system}reference with a cascade walks the same way on master. Production has 11, none over 12,587 concepts, so these would be the first over the large sources. -
Proposed:
- the data step first;
- then rebuild only what it keeps, through the async path, off-peak, one at a time, the three largest last;
- separately,
traversedas a set, which removes the squared part (about 4 minutes of the largest) with no change in behaviour.
I've left the set out of this PR, because it changes code that runs with the toggle off.
There was a problem hiding this comment.
Thanks for counting and timing these. 22 of 25 is enough to plan the rebuilds as you propose (async, off-peak, one at a time, largest last), and the traversed set as its own PR is fine by me.
…nd REFERENCE_SEARCH_OPTIONS_TOGGLE, off everywhere With the toggle off, a reference's search options are matched as fields, as on master today, so nothing changes when this merges. With it on, they apply to `q` and options alone select what a reference with no filter selects, retired content included, as references did before Jul 2025. - REFERENCE_SEARCH_OPTIONS_TOGGLE: a new row in toggles.json, off in every environment. - Gated: search options set aside instead of matched as fields, options alone selecting the version without the index, and a search URL's `q` text read the search API's way. The allowed properties and the filter errors are as on master. - Tests: the restored behaviour with the toggle on; master's with it off (options-only, `q` with options, verbose alone, a quoted `q`, the clause properties); an options-only reference added to an expansion and rebuilt with the toggle off and on; the fixture ships it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTi2oWEe5q1Dj7NkUp
…reference's description leaves its search options out
A search option only changes how `q` matches, so the description no longer reads it as a property match
("having excludeWildcard equal to ..."). With the toggle off, the description is as before, since the options
are still matched as fields then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AaZ4qTi2oWEe5q1Dj7NkUp
…toggle off, `q` is matched by master's own code - With the toggle off, or no search option, `q`'s matches are built as on master (an option read in the search API's spelling, the text as it is, the matches AND-ed), so not even the query sent differs. - With it on, another spelling of exactMatch (ExactMatch) is a property it can't apply, as for the other options, instead of being set aside. - The toggle is read only for a filter with a search option. - The toggle's fixture row is pk 14, since 13 is taken on another open branch. - The fixture test turns the toggle on in every environment column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTi2oWEe5q1Dj7NkUp
…n asks has_search_option, and a test asserts the text Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qTi2oWEe5q1Dj7NkUp
|
Review answered in e92e022, b95a5e3, cd0db49 and ef86e19.
The fixes had three Codex checks (5 findings, all fixed, then clean twice) and a simplification review (2 of 5 cuts applied). Full gate on ef86e19: pylint 10.00; 814 search-index tests OK; the other 4,061 OK on a rerun; coverage 97%. The first run had one failure in a timing test in |
snyaggarwal
left a comment
There was a problem hiding this comment.
Review round 2 (Sunny): verdict approve
Reviewed at ef86e19, against round 1 at 0be05b8. All four round-1 findings are fixed. One new nit, for the data step.
| # | Round 1 | Status | Commit |
|---|---|---|---|
| 1 | blocking: ships with nothing gating it (models.py:1363) |
fixed: behind REFERENCE_SEARCH_OPTIONS_TOGGLE, off everywhere |
e92e022, cd0db49 |
| 2 | should fix: comment said "as that search lists it", retired content not split out (models.py:1256-1258) |
fixed: reworded, numbers split into active and retired | e92e022 |
| 3 | should fix: options-only references with cascade (models.py:1363) |
answered: 22 of 25 cascade, about 20 to 30 minutes per rebuild for the largest three locally; rebuild plan proposed | thread reply |
| 4 | nit: description read the options as property matches (translators.py) |
fixed under the toggle, with a test | b95a5e3, ef86e19 |
New findings
| Severity | Where | Finding |
|---|---|---|
| nit | core/collections/models.py:1295 |
With the toggle on, another spelling of exactMatch (ExactMatch) makes the reference select nothing, where master sets the entry aside. Count these in the #797 data step too. |
Does merging change behaviour for existing users with the toggle off? No. I checked each changed path against master:
get_filter_clause_property: off, the options fall through to master's branches and are matched as fields. AddingexactMatchtoSEARCH_MODIFIER_FILTER_PROPERTIESchanges nothing off, sinceto_snake_casealready makes it a modifier andget_filter_errorsalready knew it through the case-switch list.qmatching: off,_get_search_criterion_as_beforeis master's code line for line. The rewrittenhas_param_in_filteris only called on the toggle-on path._apply_filters: options alone return the whole version only with the toggle on; off, they reach the index search as on master.- Description: off, it reads as before.
- Stored reference results, rebuilds and
dry_run_rebuildall go through these, so they match master. Parsers are unchanged. - The only difference off is a small
togglesquery for references whose filter has a search option. A filter without one never reads the toggle (tested).
Toggle: read per call through Toggle.get, with no cache, like the other expansion toggles. That means ExpansionDryRun, which patches Toggle.get, can preview the 25 with this toggle on before the data step. The fixture row follows the file's pattern, is off in all six columns, and load_fixtures applies it on container start. Tests default to off (the fixture test checks this) and use a patch to turn it on or off.
Toggle-off tests: filter clauses, filter errors, q matching (including the exact query master builds), the description, and an options-only reference added to an expansion and rebuilt off, on and off again.
#1088: it copies the ungated version of this fix (get_search_modifier set aside with no toggle), so it needs to use this toggle too, or take this code after this PR merges.
Credit: the author checked the toggle-off tests against master's own code and showed they fail on 0be05b8. The pre-Jul 2025 history check, the active/retired split, the corrected concept total and the cascade timings are all theirs. Three Codex passes and a simplification pass went in before this round.
CI: Pylint, Tests and Snyk all pass on ef86e19.
What I could not verify: I ran no tests and made no staging or production queries, so I relied on CI and on the author's counts and timings. I did not run ExpansionDryRun with the toggle on.
| is_modifier = bool(prop) and ( | ||
| to_snake_case(prop) == 'exact_match' or prop in self.SEARCH_MODIFIER_FILTER_PROPERTIES) | ||
| if is_modifier and not self.get_search_modifier(prop) and self.is_search_options_on(): | ||
| return False # another spelling of exactMatch (ExactMatch): only the two spellings count |
There was a problem hiding this comment.
nit (for the #797 data step). With the toggle on, a filter entry spelled ExactMatch (or any spelling other than exactMatch and exact_match) now can't be applied, so its reference selects nothing and shows filter_not_applied. On master that entry is set aside and the rest of the filter still runs. That is consistent with the other options, so I wouldn't change the code.
Fix: when the data step counts references, also count ones with another spelling of exactMatch, since they would shrink when the toggle goes on. I expect zero.
… fix (ee68373), so it comes from #1089 with its toggle ee68373 copied an earlier head of #1089 into this branch, without the REFERENCE_SEARCH_OPTIONS_TOGGLE that #1089 now keeps it behind. With the switch off, that changed what references with search options select. The next commit merges its head instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVC3osEQxNxh6dcRnV
The search options fix, behind REFERENCE_SEARCH_OPTIONS_TOGGLE (off everywhere), so with the switch off a reference with search options selects what it selects on master. This branch now stacks on #1089 as well as on its base. Conflicts: the index path is #1089's, now get_index_filter_clause_property, which get_filter_clause_property calls when filters aren't matched in the database. The database path is unchanged here; the next commit makes it follow the same toggle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVC3osEQxNxh6dcRnV
…es), which the FHIR series builds on fhir-452-b-codes ends the queue of OCL API PRs, so the FHIR series sits on all of them: #1085, #1086, #1089, #1088, #1087, #1090, #1091, #1092 and #1093, and the core changes that need them together. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qV2gzsF5GhF5BwTJ6x
Brings in #1085, #1086, #1082 and #1073. The two conflicts were adjacent additions (master's EXPANSION_FHIR_RULES_TOGGLE and evaluation import next to this branch's REFERENCE_SEARCH_OPTIONS_TOGGLE); both are kept. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWUTom6BGgjQy6oehZ
…merge into fhir-452-b-filters Takes #1089's new head, so this branch holds the commit that will reach master. No change to the files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWUTom6BGgjQy6oehZ
Brings in the squash merge of #1089, whose original commits this branch already holds, and #1109 and #1106. The conflicts are where #1109 changed #1089's lines: models.py keeps this branch's side, and the toggle and its test are master's, so REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment. The squash matches the original commits byte for byte, and this branch's diff against master is the same as before. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
Brings in #1089, #1109 and #1106. The one conflict is the constants import in core/collections/models.py, where both sides add a name: both are kept. The toggles are master's, so REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…into fhir-452-b-apart Takes #1087's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…o fhir-452-c-storage Takes #1090's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-imports Takes #1103's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. The one conflict is the constants import in core/collections/models.py, where both sides add names: all are kept. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-codes Takes #1088's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…nto fhir-452-b-codes Takes #1091's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. The one conflict is an import line in core/collections/models.py, next to one this branch changed: this branch's is kept. No change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…o fhir-452-c-core Takes #1094's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
… fhir-452-b9-valueset Takes #1104's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
… into fhir-452-capabilities Takes #1102's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…d into fhir-452-stored-ops Takes #1083's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…into fhir-452-b-engine Takes #1084's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…to fhir-452-b-workspace Takes #1095's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
… into fhir-452-b-expand Takes #1096's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…to fhir-452-b-validate Takes #1097's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…into fhir-452-b-ops Takes #1098's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
…fhir-452-c-fhir Takes #1099's new head, which brings in master (#1089, #1109 and #1106): REFERENCE_SEARCH_OPTIONS_TOGGLE is on in every environment, as on master. Merged cleanly; no change to this branch's own code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVQviVc1p6MQwqUUed
Not part of the Dec 1 run.
Merging this changes nothing. The fix is behind a new toggle,
REFERENCE_SEARCH_OPTIONS_TOGGLE, off in every environment. Turn it on only after the data step for the references that never added anything is decided (OpenConceptLab/ocl_online#797); the date it goes on waits for that decision. Until then, rebuilding the 61 collection versions below on master still empties them, with the toggle off too.Ticket: OpenConceptLab/ocl_online#452 (OCL API fix).
What was wrong
A collection reference can be made from a pasted search URL, such as
/orgs/O/sources/S/concepts/?q=fever&excludeWildcard=true&excludeFuzzy=true&includeSearchMeta=true. Its filter then carries that search's options:excludeWildcard,excludeFuzzy,includeSearchMeta,searchMapCodes,exactMatch,verbose.The change for ocl_issues#2201 (Jul 2025) made camelCase filter properties work, such as
conceptClass. Its switch also caught these options:exclude_wildcardand so on), so the reference selected nothing.What changes with the toggle on
excludeWildcardandexclude_wildcard(and so on) are recognised before the camelCase switch, and never matched as fields.conceptClassand the other camelCase properties work as before.qas the search API applies them. Matches are exact, plus wildcard matches whenexcludeWildcardis false, plus fuzzy matches whenexcludeFuzzyis false.searchMapCodesfalse leaves out map codes, and a repeated option takes its last value.excludeWildcard=falsedo almost nothing. They're now OR-ed, as in the search API.activeOnlystill leaves retired content out.With the toggle off (every environment, as shipped)
Everything is as on master today, and master's own code runs:
get_filter_clause_property,get_allowed_filter_properties,get_filter_errorsand the description are master's, so the options are matched as fields;qis matched by master's code (_get_search_criterion_as_before), so even the query sent is the same;toggles.jsonis loaded on every container start, so turning the toggle on is a change to its row there (pk 14).Impact on a rebuild (production, read-only counts)
207 references carry these options (162 camelCase, 45 snake_case), in 124 collection versions, 42 of them active HEADs. Every one sets all three of
excludeWildcard,excludeFuzzyandincludeSearchMetatotrue, so theirqmatching is exact either way.sourcetoconceptsorsourcemappings). A rebuild callscascade()once per concept of the target version: 1,423,154 calls if each is rebuilt once. Measured locally, that's about 20 to 30 minutes for each of the three largest (252,212 to 286,477 concepts) and 4 to 6 minutes for each of nine with 58,947. Production wasn't measured. These should be rebuilt through the async path, off-peak.Tests
CollectionReferenceTest, with the toggle on:q, selects the whole version (concepts and mappings), retired included, and exactly what a reference with no filter selects, a release with or without its version named, the resource-versions toggle on and off;retired=falseand withconceptClass;qwith the options,excludeWildcard=falseOR-ed in,excludeFuzzy=false(with an uppercase typo), andsearchMapCodes=false;qfrom a search URL, and aqalone with a literal apostrophe.qwith options select nothing,verbosealone still goes through the index, a quotedqis read as it is,q's query built as master builds it), and master's clause properties and filter errors. The same checks were also run against master's own code, with the same results, and fail on this PR's previous head.ExactMatch) is reported as a property it can't apply.is_search_options_onreads.get_filter_clause_property(each spelling, both toggle states),get_filter_errorsandhas_param_in_filter.ef86e199: pylint 10.00; 814 search-index tests OK; the other 4,061 (2 skipped) OK on a rerun; coverage 97%. The first run had one failure in a timing test incore.capacity, which this PR doesn't touch; it passes alone, and passed in the gate oncd0db49d.Review
Three Codex defect passes (5, 4 and 2 findings), a simplification review (4 of 5 cuts applied), and two Codex checks of the later commits (1 finding each). Fixed along the way:
qthat way for exact matches too, while aqalone is matched exactly as before;Sunny's review (the toggle, retired content, the cascade cost, the description) is answered in its threads. Its fixes had three Codex checks (5 findings, all fixed; then clean twice) and a simplification review (2 of 5 cuts applied).
Not fixed here:
searchMapCodes=false&searchMapCodes=) for every property.q=""is an exact search for empty text.qand a display-only option reads its text the search URL's way.No production reference has any of the last three.
Merged master after #1085 and #1086 (
3980d7d7); no change to the reviewed code.🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qTi2oWEe5q1Dj7NkUp