-
Notifications
You must be signed in to change notification settings - Fork 50
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
Optimise search excerpt to highlight more relevant results #1075
Conversation
✅ Deploy Preview for laughing-payne-b9fbd2 ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! This is a nice DRY up. Just a few quick comments on superficial things, but otherwise I think it's good to go
The first two commits could probably be squashed, but it does tell a story as is, so I'm easy
e148669
to
a55d57b
Compare
Currently a search excerpt is generated by searching for the index of each separate term and selecting the first match for the first word (or the first match for the second if it is not found). Here have added a search for the full term, so that an excerpt containing a full match will be prioritized over one containing just one word. The function uses two variables: information for the first (if any) full match, and a list of information on the first match for each word in the search query. Even if a full match is found, the list of individual term matchers is used for highlighting terms in the excerpt display.
a55d57b
to
fdac5dc
Compare
For consistency with the rest of file.
Currently a search result excerpt is generated by searching for the index of each separate term and selecting the first match for the first word (or the first match for the second if it is not found). This means that when selecting the first excerpt from the page it may not be the most relevant to the user as it may contain the first term only when there is a result lower down the page which contains the full term. (Issue #1074 )
This change looks for an excerpt containing the full search term first, so a full match will be prioritised over one containing just one word.
A few considerations:
Resolves issue #1074