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

Upstream issue #11961: alternative de-duplication approach #1

Conversation

jayaddison
Copy link

Feature or Bugfix

  • N/A - discussion pull request.

Purpose

Detail

  • Drop the title field from the search result de-duplication key (resultStr).

Relates

  • N/A

@jayaddison jayaddison changed the title Upstream issue #11942: alternative de-duplication approach Upstream issue #11961: alternative de-duplication approach Feb 7, 2024
@@ -345,7 +350,8 @@ const Search = {
// note the reversing of results, so that in the case of duplicates, the highest-scoring entry is kept
let seen = new Set();
results = results.reverse().reduce((acc, result) => {
let resultStr = result.slice(0, 4).concat([result[5]]).map(v => String(v)).join(',');
const [docName, _title, anchor, descr, _score, filename] = result;
const resultStr = `${docName},${anchor},${descr},${filename}`;
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, I don't see how this would pass the test below. 🤔 The body search and title search will have different resultStr's (since they have different anchors), so you'd see them both in the results.

Copy link
Author

Choose a reason for hiding this comment

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

The test does succeed with that - could that imply a bug in the test?

Copy link
Owner

Choose a reason for hiding this comment

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

There's only one search result because my other fixes haven't been applied (I left them out for ease of review). If you rebase your branch on top of these pull requests the test should start failing:

sphinx-doc#11960
sphinx-doc#11958

Copy link
Author

Choose a reason for hiding this comment

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

Hm. Are you sure? I can still get the test to pass with a docid of 1 instead of zero, and the partial-matching only affects the scoring, if I understand correctly?

Copy link
Owner

Choose a reason for hiding this comment

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

Took a look, I think it's actually sphinx-doc#11959 (the multiple matches) that allows multiple results to be generated as you'd expect. If you apply this squashed patch your tests should start failing: https://gist.github.com/wlach/74124608c2113d8eb9737cdced4762db

Copy link
Author

Choose a reason for hiding this comment

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

Bug raised as sphinx-doc#11965.

Copy link
Owner

Choose a reason for hiding this comment

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

A further change may be needed to duplicate between those client-side, yes, but I think it could be simplified (more like e2d07a1) if the duplicate titles index entries are removed.

Hmm, I'm confused-- that looks similar to my original solution which you rejected here:

sphinx-doc#11942 (comment)

Copy link
Author

Choose a reason for hiding this comment

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

It's not ideal, but it's smaller -- there's no isDocumentTitle, and no additional boolean passed down to the de-duplication phase.

Copy link
Author

Choose a reason for hiding this comment

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

(and in fact, it might not even be required. if the index-construction issue is valid and fixed, then we could try removing it and relying purely on an updated de-duplication key)

Copy link
Owner

@wlach wlach Feb 7, 2024

Choose a reason for hiding this comment

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

It's not ideal, but it's smaller -- there's no isDocumentTitle, and no additional boolean passed down to the de-duplication phase.

Ok, I don't have a super strong opinion: I thought your original critique had a point but I don't think it matters all that much in the end.

(and in fact, it might not even be required. if the index-construction issue is valid and fixed, then we could try removing it and relying purely on an updated de-duplication key)

I am pretty sure we still have the problem of the title search / term search returning more-or-less the same result. The unit test uses a hand-constructed index without this problem and still reproduces the bug.

@wlach
Copy link
Owner

wlach commented Feb 27, 2024

I'm going to close this as it looks like the discussion has ended and I'm satisfied with my approach in sphinx-doc#11942

@wlach wlach closed this Feb 27, 2024
@jayaddison jayaddison deleted the issue-11961/pr-11942-review-experimentation branch February 27, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants