Skip to content
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

Merged
merged 3 commits into from
Sep 26, 2018

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Sep 25, 2018

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 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.
@nik9000 nik9000 added review :Search/Search Search-related issues that do not fall into other categories v7.0.0 v6.5.0 labels Sep 25, 2018
@elasticmachine
Copy link
Collaborator

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())) {
Copy link
Member Author

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"));
Copy link
Member Author

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.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jpountz jpountz left a 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.

@nik9000 nik9000 merged commit 1871e7f into elastic:master Sep 26, 2018
@nik9000 nik9000 removed the v6.5.0 label Sep 26, 2018
@nik9000
Copy link
Member Author

nik9000 commented Sep 26, 2018

Thanks for reviewing @jpountz and @jimczi! I'm going to backport this fairly carefully and open a new PR for it because supporting 5.x indices requires a little more care.

@nik9000
Copy link
Member Author

nik9000 commented Sep 26, 2018

Now that I'm looking at the backport more closely, I'm tempted to not pull this back to 6.x at all. uid support isn't really compatible with this change and 5.x support looks tricky as well. So, at least for now, I'm going to leave this as a master only change.

kcm pushed a commit that referenced this pull request Oct 30, 2018
`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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants