Unified highlighter for association search (hl.method=unified) - #1361
Unified highlighter for association search (hl.method=unified)#1361kevinschaper wants to merge 1 commit into
Conversation
Set hl.method=unified on the association free-text search so highlighting reads offsets from the postings (storeOffsetsWithPositions) instead of term vectors. Pairs with monarch-initiative/monarch-ingest#708, which drops term vectors from the `text` field type to shrink the index and speed indexing. Solr 8 defaults to the `original` highlighter, which uses term vectors and does NOT read postings offsets, so without this change highlighting would fall back to slow per-result re-analysis once term vectors are gone. Adds an optional hl_method field to SolrQuery (serialized to hl.method); None by default, so all other queries are unchanged. Companion still needed: frontend should stop wrapping q in wildcards and rely on the analyzed _t fields already in the qf. Claude-Session: https://claude.ai/code/session_012eRPzupZErBJN7495bWEVD
✅ Deploy Preview for monarch-app canceled.
|
|
Review Small, well-scoped change - thanks for the clear PR description explaining the Solr internals. One correctness issue and a scope question below. Breaks existing unit tests Adding
query = build_association_query(...).model_dump()
expected = association_query_direct # a plain dict fixture
assert compare_dicts(query, expected)and def compare_dicts(dict1, dict2):
return all([k in dict2 for k in dict1]) and all([dict1[k] == dict2[k] for k in dict2])This requires every key in the actual dict ( That means these tests should now fail (based on reading the code/fixtures - wasn't able to execute pytest to confirm at runtime, so please double check):
The PR description says " Scope question: entity/autocomplete search also highlights via the same field type
Minor
Otherwise the |
What
Sets
hl.method=unifiedon the association free-text search (adds an optionalhl_methodfield toSolrQuery, serialized tohl.method;Noneby default so other queries are unchanged).Why
Pairs with monarch-initiative/monarch-ingest#708, which drops term vectors from the
textfield type (big index-size + indexing-speed win). Solr 8's defaultoriginalhighlighter uses term vectors and does not read postings offsets; the Unified highlighter reads thestoreOffsetsWithPositionsoffsets that PR adds. Without this, highlighting would fall back to slow per-result re-analysis once term vectors are gone.Must ship together with the ingest PR.
Still needed (frontend)
Stop wrapping
qin*…*wildcards; rely on the analyzed_tfields already in theqf(the backend passesqthrough raw —solr_query_utils.py:132).Tests
tests/unit/test_datamodels_solr.pypasses (11/11);hl_methoddefaults toNoneso it's omitted from every existing query string.https://claude.ai/code/session_012eRPzupZErBJN7495bWEVD