opensafely-core / ehrql

ehrQL: the electronic health record query language for OpenSAFELY
https://docs.opensafely.org/ehrql/
Other
7 stars 3 forks source link

Search returns "raw" schemas before other schemas #2086

Open evansd opened 3 months ago

evansd commented 3 months ago

Searching for tables which appear in both "cooked" and "raw" schemas returns the raw schema first, which confuses users.

For example: image

Thread where this confusion arose: https://bennettoxford.slack.com/archives/C04DVD1UQC9/p1709896596557359

evansd commented 3 months ago

This could be solved using the same approach as used here:

We'd need to update the code which gets information about the schemas to return an is_raw flag for each schema: https://github.com/opensafely-core/ehrql/blob/f5b0d5f56b53039062cf1f95ea76dda584f485de/ehrql/docs/schemas.py#L43-L52

Probably this would just be based on the module name as I don't think we have anything more structured to use here.

Then the code which renders the schemas to Markdown would need to add a metadata header to the page which configures the search boost appropriately: https://github.com/opensafely-core/ehrql/blob/f5b0d5f56b53039062cf1f95ea76dda584f485de/ehrql/docs/render_includes/schemas.py#L40-L63

For raw pages I imagine something like this would do the trick, but we'll need to experiment with the boost values a bit:

---
search:
  boost: 0.001
---