-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add explicit search query option. #2592
Merged
Hyperkid123
merged 3 commits into
RedHatInsights:master
from
Hyperkid123:fix-search-argument
Aug 7, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could the search query build be moved to a separate function?
Can the URL prams be build safely using a URL builder instead of search and replace? For example with
URLSearchParams
.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.
The query is built with
URLSearchParams
and then the URL is built withURL
classes on the top of the file. The search endpoint currently does not allow encoded query string. It had to be disabled a few months back. Therefore there is no point in rebuilding the query on each request and the creating was lifted out of the callback to be static and save some resources.Currently, the replace method is as good as using the search params constructor.
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.
Okay, I've missed the use of
URLSearchParams
.Do we escape special characters within the search query?
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.
As I said, the search API does not support encoded/escaped characters. You can see that we actually have to decode the query params before using them in the query. My assumption is that the API requires special characters like
*
or~
to build a valid SOLR query. But you would have to ask the search team for details.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.
Which API does not support encoded URI (query string)? Is that SOLR? Query string is part of the standard of RFC3986.
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.
Found the references:
@Hyperkid123 do you have more info on the reason or can you ask the search team please? Was it reported to them?
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.
I'm trying to send encoded ampersand
%26
to stage API, it does not fail. However, not encoding these characters leads to HTTP 400.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.
I do not have any formal records. Discussion with the search team happened on a chat. I understand the encoded strings are part of the spec. The hydra API was returning 400 responses when we tried to send encoded queries.
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.
Discussed with Martin offline. IMO we will need to follow up on the URL encoding in a separate pull request - that way we can revert either (or both) PRs if there is an issue. It seems the search team fixed an issue with the Hydra REST endpoint that was originally causing the 400's (see slack thread). We should now be able to send the encoded special characters in the SOLR queries.