-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(search): Search not returning result if query text contains forward slash #10932
fix(search): Search not returning result if query text contains forward slash #10932
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe primary change modifies the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java (1 hunks)
Additional comments not posted (2)
datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java (2)
74-74
: Correct implementation of forward slash escaping.The change from
\\\\/
to\\/
for escaping forward slashes is correct and aligns with ElasticSearch guidelines. This should resolve the issue with search queries containing forward slashes not returning expected results.
74-74
: Verify the usage ofescapeForwardSlash
across the codebase.Ensure that the change in the escaping logic does not affect other functionalities where this method is used.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- datahub-frontend/app/utils/SearchUtil.java (1 hunks)
- datahub-frontend/test/utils/SearchUtilTest.java (1 hunks)
- datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java
Additional comments not posted (3)
datahub-frontend/test/utils/SearchUtilTest.java (2)
11-11
: Updated test case for escaping forward slashes.The test case correctly reflects the new escape sequence for forward slashes, aligning with the changes in the
escapeForwardSlash
method.
14-14
: Updated test case for mixed characters.This test case ensures that forward slashes are escaped while asterisks are not, maintaining regex behavior. It properly tests the updated functionality.
datahub-frontend/app/utils/SearchUtil.java (1)
23-23
: Correct implementation of the forward slash escaping.The modification in
escapeForwardSlash
method correctly updates the escape sequence for forward slashes (/
to\\/
). This change aligns with the PR's objective to fix search issues related to forward slashes in Elasticsearch 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.
I think the issue here is that SimpleQueryStringBuilder
is not always involved in the query. For the cases when SimpleQueryStringBuilder
is not used I believe the quoting is correct. We likely need to apply your suggested change only when SimpleQueryStringBuilder
is used.
@david-leifker
So considering this, I think that the fix provided on this PR on datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ResolverUtils.java should be necessary to fix this issue, wdyt? |
Thanks! |
We recently discovered an issue while performing Search operation on Datahub.
Issue: When a search query text contains a forward slash
/
, Search result does not return the expected result.As an example:
We have a dataset exists on datahub with Name:
databox.arn:aws:s3:::dl-odin-pro-datalake-16vmobiqqrhwn/odin/v2/autotrader-au/notification
When we search with the query text
databox.arn:aws:s3:::dl-odin-pro-datalake-16vmobiqqrhwn/odin/v2/autotrader-au/notification
from Datahub UI or GraphQL API, the search result does not return any result.Fix:
Instead of 4 preceding backslashes "
\\\\
" we need to use 2 preceding backslashes "\\
" while escaping Forward Slash.(forward slash/
is a reserved character in elastic search)The Problem was when we were searching with an input query string
databox.arn:aws:s3:::dl-odin-pro-datalake-16vmobiqqrhwn/odin/v2/autotrader-au/notification
theescapeForwardSlash
method of ResolverUtils.java converted the input query string intodatabox.arn:aws:s3:::dl-odin-pro-datalake-16vmobiqqrhwn\\/odin\\/v2\\/autotrader-au\\/notification
(added 2 backward slashes) then the query string again JSON Stringified bySimpleQueryStringBuilder
while building the Search Query, so the final query string becamedatabox.arn:aws:s3:::dl-odin-pro-datalake-16vmobiqqrhwn\\\\/odin\\\\/v2\\\\/autotrader-au\\\\/notification
with additional 2 extra back ward slashes (\). Due to this, the elastic search query was failed to return any record.Test Result with the fix:
Note:
We also found that this class (datahub-frontend/app/utils/SearchUtil.java) also have the similar code
datahub/datahub-frontend/app/utils/SearchUtil.java
Line 23 in 82e5a04
Checklist
Summary by CodeRabbit