Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/src/monarch_py/datamodels/solr.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class SolrQuery(BaseModel):
boost: Optional[str] = None
sort: Optional[str] = None
hl: bool = False
hl_method: Optional[str] = None # e.g. "unified" — reads offsets from postings (storeOffsetsWithPositions)

def add_field_filter_query(self, field: str, value: Union[list, str, None]):
if not value or len(value) == 0:
Expand Down Expand Up @@ -141,6 +142,8 @@ def _solrize(self, value):
return "defType"
elif value == "q_op":
return "q.op"
elif value == "hl_method":
return "hl.method"
elif value is True:
return "true"
elif value is False:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def build_association_query(
query.q = q
query.def_type = "edismax"
query.hl = True
# Unified highlighter reads offsets from the postings (storeOffsetsWithPositions),
# so highlighting no longer needs term vectors on the _t fields.
query.hl_method = "unified"
query.query_fields = association_search_query_fields()
if sort:
query.sort = ", ".join(sort)
Expand Down
Loading