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

fix MultiValuesSourceFieldConfig toXContent #36525

Merged
merged 3 commits into from Dec 13, 2018
Merged

Conversation

talevy
Copy link
Contributor

@talevy talevy commented Dec 12, 2018

This commit turns MultiValuesSourceFieldConfig into a proper
ToXContentObject for easy testing and verification of its
to/from XContent methods.

Closes #36474.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo

@talevy
Copy link
Contributor Author

talevy commented Dec 12, 2018

@polyfractal I was interested in adding actual tests for the aggregation as well since I couldn't find any. Do we have to/from xcontent tests somewhere for the weighted_avg aggregation?

I tried my hand, but
ran into issues where it isn't clear how to parse the toXContent version of things. Looks like things are inconsistent?

For example, here is a snippet of the generated xcontent:

{“vOdlQXAnYr”:{“weighted_avg”:{“fields”:{“weight”:{“field”:“weight_field”},“value”:{“field”:“value_field”}}}}}

There is an extra fields field that differs from the vanilla query-dsl format.

@talevy
Copy link
Contributor Author

talevy commented Dec 12, 2018

I assume I am missing some context, but I went ahead and added a second commit that demonstrates what I meant by my previous comment

Copy link
Contributor

@polyfractal polyfractal left a comment

Choose a reason for hiding this comment

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

Thanks @talevy! Left a few comments, otherwise LGTM.

Should this target master, not just 6.x?


@Override
protected WeightedAvgAggregationBuilder doParseInstance(XContentParser parser) throws IOException {
parser.nextToken();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we snag the code from BaseAggregatorTestCase#parse() so that we have a similar set of assertions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh woah, yeah, I'll lift that...

thanks for the pointer, was looking for something like that to re-use

@@ -78,7 +79,7 @@ private MultiValuesSourceFieldConfig(String fieldName, Object missing, Script sc
}

public MultiValuesSourceFieldConfig(StreamInput in) throws IOException {
this.fieldName = in.readString();
this.fieldName = in.readOptionalString();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that if we want to change this, we might need to wrap this in version checks? readOptionalString() encodes an extra byte for the boolean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. maybe we can do this in a separate PR. I think Docs need clean up too. We claim that field is required, but it can be replaced with script.

I see this as a bug, but want to attack this separately since the original issue was only with XContent.

Copy link
Contributor

Choose a reason for hiding this comment

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

++ makes sense to me

This commit turns MultiValuesSourceFieldConfig into a proper
ToXContentObject for easy testing and verification of its
to/from XContent methods.

Closes elastic#36474.
@talevy talevy changed the base branch from 6.x to master December 13, 2018 02:20
@talevy
Copy link
Contributor Author

talevy commented Dec 13, 2018

Hey @polyfractal, I know you approved this, but I've reverted the serialization changes, mind taking another look?

As I said previously. the bug in the serialization is not the concern of this PR.

Copy link
Contributor

@polyfractal polyfractal left a comment

Choose a reason for hiding this comment

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

👍 looks good! ++ to doing the serialization stuff in a followup PR (agree it's a bug and the docs should be updated to match)

@talevy talevy merged commit b820d7c into elastic:master Dec 13, 2018
@talevy talevy deleted the fix-36474 branch December 13, 2018 16:17
@talevy
Copy link
Contributor Author

talevy commented Dec 13, 2018

thanks for the review @polyfractal!

talevy added a commit that referenced this pull request Dec 13, 2018
This commit turns MultiValuesSourceFieldConfig into a proper
ToXContentObject for easy testing and verification of its
to/from XContent methods.

Closes #36474.
talevy added a commit that referenced this pull request Dec 13, 2018
This commit turns MultiValuesSourceFieldConfig into a proper
ToXContentObject for easy testing and verification of its
to/from XContent methods.

Closes #36474.
@talevy talevy added the v6.5.4 label Dec 13, 2018
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Dec 13, 2018
* elastic/master:
  Remove deprecated `useDisMax` from MultiMatchQuery (elastic#36488)
  HLRC: Add get users action (elastic#36332)
  fix MultiValuesSourceFieldConfig toXContent (elastic#36525)
  Add ILM-specific security privileges (elastic#36493)
  Remove usages of `MockTcpTransport` from zen tests (elastic#36579)
@RussellSpitzer
Copy link

This is also broken on the 6.4 branch, would it be possible to back port the fix there as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants