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.
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
Adds a new parameter, max_analyzer_offset, for the highlighter #3893
Adds a new parameter, max_analyzer_offset, for the highlighter #3893
Changes from 8 commits
f0d9805
6be297d
4c6ff70
595bb04
1b63fad
ba381be
c63d527
ed80f5f
5a0e1dc
6b5c529
f95599a
bf612f0
f8e3f2a
53b3b87
70cf4bb
f21a416
257cb18
7a03514
cff3e7a
e33b80e
24dec06
f2ef792
4b25f5c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Questions: do we need to keep track of both
maxAnalyzedOffset
&&fieldMaxAnalyzedOffset
? I think we could useMath.max(maxAnalyzedOffset, fieldMaxAnalyzedOffset)
, no? I believe the purpose of thefieldMaxAnalyzedOffset
is to override themaxAnalyzedOffset
on per query basis: it could be lower or higher value, right?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.
Actually with this implementation it could only be lower, I don't know if the maxAnalyzedOffset has an impact when indexing as it is an index option. Because of this if fieldMaxAnalyzedOffset is higher than maxAnalyzedOffset and the field lenght is higher than maxAnalyzedOffset an exception still occurs.
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.
Than we could go with
min(fieldMaxAnalyzedOffset, maxAnalyzedOffset)
, right?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.
Right, but that will change the current behavior, because now if the text is bigger than the maxAnalyzedOffset an exception is throw, with the suggested approach it will pass, but will not highlight items after maxAnalyzedOffset. For me this behavior is better, but it will break some tests. This was my original idea, I changed to not break the tests.
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.
To be fair, it looks confusing (to me at least), when I look how it is being used:
(fieldMaxAnalyzedOffset < 0 || fieldMaxAnalyzedOffset > maxAnalyzedOffset)
- this is static information, could be precomputed in the constructor ahead of time totrue
orfalse
. Now, iffieldMaxAnalyzedOffset < maxAnalyzedOffset
, this compound condition evaluates to 'false' no matter what. It looks to me the intent should be:But in this case, the exception is now hiding 2 problems:
fieldValueLength > maxAnalyzedOffset
andfieldMaxAnalyzedIsNotValid
- we have to split these failures into 2 with all contextual information provided.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.
Yes, this can be done in the constructor, and I think that your if statement is exactly what I intend. I will update this.
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.
Actually it should be
if ((offsetSource == OffsetSource.ANALYSIS) && (fieldValueLength > maxAnalyzedOffset && fieldMaxAnalyzedIsNotValid)) {
as it must only throw the exception if thefieldMaxAnalyzedIsNotValid
. This is because when it is valid the text will be cut fitmaxAnalyzedOffset
.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.
But what about
fieldValueLength > maxAnalyzedOffset
check?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.
We can cast another exception for when the
fieldMaxAnalyzedOffset > maxAnalyzedOffset
, I think that, indeed this should be better.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.
Please see if now it is more clear what is going on.