-
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
Add explicit search query option. #2592
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #2592 +/- ##
==========================================
- Coverage 57.60% 52.48% -5.12%
==========================================
Files 92 92
Lines 2788 2450 -338
Branches 699 503 -196
==========================================
- Hits 1606 1286 -320
+ Misses 1140 763 -377
- Partials 42 401 +359 |
@@ -196,7 +196,7 @@ const SearchInput = () => { | |||
}, [isOpen, menuRef]); | |||
|
|||
const handleFetch = (value = '') => { | |||
return fetch(SEARCH_QUERY.replace(REPLACE_TAG, value).replace(FUZZY_RANGE_TAG, value.length > 3 ? '2' : '1')) | |||
return fetch(SEARCH_QUERY.replaceAll(REPLACE_TAG, value).replaceAll(FUZZY_RANGE_TAG, value.length > 3 ? '2' : '1')) |
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 with URL
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.
/retest |
/retest |
Jira: https://issues.redhat.com/browse/RHCLOUD-27216
In addition to a wildcard search option add some variants and also an explicit term query to bypass the expected character. Gives higher priority to the explicit search matches.
Primarily deals with issues when an exact query does not match the search term.