-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Search: Simply SingleFieldsVisitor #34052
Conversation
`SingleFieldsVisitor` is meant to load a single stored field but it manages to be quite complex to reason about because it inherits from our "basic" `FieldsVisitor` which is designed to load many fields. This breaks that inheritance and adds logic to `SingleFieldsVisitor` so it can be properly stand alone. While this amounts to more lines of code they ought to be significantly easier to reason about.
Pinging @elastic/es-search-aggs |
} catch (IOException e) { | ||
throw new ElasticsearchParseException("failed to load field [{}]", e, name); | ||
List<Object> values; | ||
if (TypeFieldMapper.NAME.equals(data.fieldType().name())) { |
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.
This approach will not work in 6.x which has to be compatible with indices created in 5.x but I think it is quite sensible in master.
getResult.docIdAndVersion().reader.document(getResult.docIdAndVersion().docId, visitor); | ||
assertEquals(Arrays.asList(testFieldValue), visitor.fields().get("test")); |
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 suspect I could just call document(getResult.docIdAndVersion())
here and save some ceremony.
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.
LGTM
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.
👍 Agreed that it is much easier to reason about now.
Now that I'm looking at the backport more closely, I'm tempted to not pull this back to 6.x at all. |
`SingleFieldsVisitor` is meant to load a single stored field but it manages to be quite complex to reason about because it inherits from our "basic" `FieldsVisitor` which is designed to load many fields. This breaks that inheritance and adds logic to `SingleFieldsVisitor` so it can be properly stand alone. While this amounts to more lines of code they ought to be significantly easier to reason about.
SingleFieldsVisitor
is meant to load a single stored field but itmanages to be quite complex to reason about because it inherits from our
"basic"
FieldsVisitor
which is designed to load many fields. Thisbreaks that inheritance and adds logic to
SingleFieldsVisitor
so it canbe properly stand alone. While this amounts to more lines of code they
ought to be significantly easier to reason about.