Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search returns "raw" schemas before other schemas #2086

Open
evansd opened this issue Aug 13, 2024 · 1 comment
Open

Search returns "raw" schemas before other schemas #2086

evansd opened this issue Aug 13, 2024 · 1 comment

Comments

@evansd
Copy link
Contributor

evansd commented Aug 13, 2024

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
Copy link
Contributor Author

evansd commented Aug 13, 2024

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:

schemas.append(
{
"name": name,
"dotted_path": dotted_path,
"hierarchy": hierarchy,
"docstring": docstring,
"implemented_by": implemented_by,
"tables": sorted(module_tables, key=lambda t: t["name"]),
}
)

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:

SCHEMA_TEMPLATE = """\
# <strong>{name}</strong> schema
{implemented_by_list}
{docstring}
``` {{.python .copy title='To use this schema in an ehrQL file:'}}
from {dotted_path} import (
{table_imports}
)
```
{table_descriptions}
"""
def render_schema(schema):
return SCHEMA_TEMPLATE.format(
**schema,
implemented_by_list=implemented_by_list(schema["implemented_by"], depth=2),
table_imports=table_imports(schema["tables"]),
table_descriptions=table_descriptions(schema["tables"]),
)

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
---

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

No branches or pull requests

1 participant