Skip to content

Fix for #493#504

Open
tim-band wants to merge 2 commits into
developmentfrom
fix/antiquarian-match-weighs-more
Open

Fix for #493#504
tim-band wants to merge 2 commits into
developmentfrom
fix/antiquarian-match-weighs-more

Conversation

@tim-band

@tim-band tim-band commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Antiquarian name matches come higher in search results.

I have annotated each object in the results set with a weight integer. Normally this is 1, but I have a new matcher function match_heavy that sets it to 100 (giving us plenty of room for intermediate weights; although there's no problem renumbering at any time I suppose).

Fixes #493

Antiquarian name matches come higher in search results
@tim-band tim-band requested review from acholyn and tcouch June 23, 2026 10:49
Comment thread src/rard/research/views/search.py Fixed

@tcouch tcouch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

# All these objects are returned
self.assertSetEqual(set(results2), {a2, w2, f2})
# And the antiquarian is not first
self.assertNotEqual(results2[0], a2)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice explanation, but I don't think you'd want to assert that antiquarians should explicitly not come first if the match is to its intro instead of its name. If it doesn't matter to us what the order is, I wouldn't test for it.

) -> QuerySet:
"""
Get the queryset for matching one type of objects, without Latin folding,
with extra weight (so they appear at the top of the)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the top of the...? Please, I need to know! :-)

("name", terms.match_heavy),
("plain_introduction", terms.match),
("re_code", terms.match),
("re_code", terms.match_heavy),

@tcouch tcouch Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could take or leave re_code being match_heavy - as far as I can tell it doesn't tend to contain anything the name doesn't have. Although that raises the question of why it's even a search field anyway.

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

Successfully merging this pull request may close these issues.

Make antiquarian name matches weigh more in search results

3 participants