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

Handle quotation marks in search strings and adjust query result header styling #770

Merged
merged 3 commits into from
Aug 25, 2023

Conversation

dchiller
Copy link
Collaborator

This PR:

  • Adds closing quotations to the end of search strings if there is an unclosed quotation in the user-entered search string. Solr errors when there are unclosed quotations (ie. an odd number of quotation marks in the query string). In this case we assume that that user is either still typing, so we close the quotation to show intermediate results, or that the user forgot to close the quotation.
  • Previously, the searched-for query string was enclosed in quotation marks. But, since the search string itself may contain quotation marks, we change the styling.
    Old style:
    image
    New style:
    image
  • Modifies how we display the query for mode searches by adding a space between modes when multiple modes are searched.
    Old style:
    image
    New style:
    image

Closes #766.

// are not closed. If the search string contains an odd number of quotation
// marks, add a quotation mark to the end of the string.
if (["all","feast","genre","office"].includes(searchField)){
(searchInput.split('"').length - 1) % 2 === 1 ? searchInput += '"' : null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this handle single quotation marks too, and should we be concerned about quotations within quotations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It just handles double marks...

The honest reason is that solr does not complain with single marks (or many other punctuation marks that you wouldn't expect in any of our text -- eg. # @ % & etc). As far as I can tell, solr just strips out the single marks.

Solr does respond to other reserved characters when entered in the search box (eg. - and () and I do think we need a better way of making this search syntax available to the user.

In any case, single marks don't cause the error so I didn't fix them here, but it's a good point that ideally we need to figure out what's going on in these other cases.

@dchiller dchiller merged commit cb0f2df into DDMAL:main Aug 25, 2023
2 checks passed
@dchiller dchiller deleted the i-766-search-string-quotations branch August 25, 2023 15:06
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.

Error on search string with open quotation marks
2 participants