-
Notifications
You must be signed in to change notification settings - Fork 8.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 Enterprise Search document search bug in indices without position data indexed #148397
Merged
kderusso
merged 5 commits into
elastic:main
from
kderusso:kderusso/multiple-search-terms-error
Jan 4, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
35b320c
Replace stringify with raw escaped query String to avoid requiring mu…
kderusso e24a034
Tests
kderusso cbeed30
Update README with updated Jest testing information
kderusso 6689169
Merge branch 'main' into kderusso/multiple-search-terms-error
kderusso 729dd6d
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 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
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
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
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.
I'm good with this, but should we do any follow-up to ensure the query string is sanitized further?
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.
@TattdCodeMonkey That's a great question. Did you have anything specific in mind?
@sphilipse seemed to think that was sufficient because you can't really inject anything into the query at that point plus it's already behind authorization. I really dislike the idea of ad-hoc manual safety String mutations for several reasons. We could consider adding a new issue to re-do the search form so that Stringify doesn't force everything to use multi-match, but I'm not really sure what the priority is. WDYT?
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.
@kderusso The call is a
query_string
query, right? Could you describe how the multi-word query fails due to the index not supporting multi-match, e.g. show the error message? Maybe we can fix it in a different way.My concern is putting the expression in quotes forces a phrase match, which differs from the actual full text matching experience (OR semantics by default). But I agree this is low priority.
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.
@demjened Can you please help me better understand your concern here?
JSON.stringify
was quoting the query and forcing a multi-match query to be run. This removes this default behavior.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.
Ah, I thought
query
was already coming in quoted from the UI. But then why the need for.replace()
? Can't we just passq: query
as-is?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.
Users can still input a quote in the front-end, which will force a multi-match if we don't escape them.
Quick question: do we also need to escape single quotes, or only double quotes?
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.
@sphilipse I have verified that single quotes don't need to be escaped, using them doesn't error.
@demjened If we use double quotes it will force the multi-match phrase query and error. Escaping them solves this.