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

PostData<T> does not work correctly except in string case #1800

Closed
godefroi opened this issue Feb 3, 2016 · 3 comments
Closed

PostData<T> does not work correctly except in string case #1800

godefroi opened this issue Feb 3, 2016 · 3 comments

Comments

@godefroi
Copy link

godefroi commented Feb 3, 2016

In es-net 2.0.0-rc1, I have found that using PostData<T> in various scenarios resulted in odd content being posted, as verified by Wireshark. I can update this issue tomorrow with the specific examples of the data, but the only scenario that I could verify as working is the PostData<string> case. When the type is a serializable type or byte[], the correct data is not posted to the server. I did not try the IEnumerable<T> cases.

@Mpdreamz
Copy link
Member

Mpdreamz commented Feb 4, 2016

We had a pretty extensive unit test suite for PostData<> but no real integration tests. Added this and it uncovered it didn't handle boxed types very well. In the IEnumerable case it should also force no formatting.

Again thanks for opening this issue @godefroi much much appreciated 👍

@godefroi
Copy link
Author

godefroi commented Feb 9, 2016

PostData<T> still doesn't work correctly in the PostType.Serializable case. I get the following data sent over the wire to ES:

POST /unittests_record_cdooacwg55xeflhn3hxzkpjtae/record/rec.1.2.3%5Crecc?pretty=true HTTP/1.1
Accept: application/json
Content-Type: application/json
Host: 10.8.16.195:9200
Content-Length: 30

{"WrittenBytes":null,"Type":4}

Clearly it's the PostData<T> object that's being serialized, not the object that it's wrapping. This is with 2.0.1.

@godefroi
Copy link
Author

godefroi commented Feb 9, 2016

More information: Passing a PostData<Record> into ElasticLowLevelClient.Index() results in the object being cast to PostData<object>, which doesn't work as expected. Passing my Record object directly works, because of the implicit operator on PostData<T>, but passing an actual instance of PostData<T> where T is not object does not work as expected. Instead of the method signature being:
Index<T>(string index, string type, string id, PostData<object> body, Func<IndexRequestParameters, IndexRequestParameters> requestParameters = null)

It should probably be:
Index<T>(string index, string type, string id, PostData<T> body, Func<IndexRequestParameters, IndexRequestParameters> requestParameters = null)

This would eliminate the cast.

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

No branches or pull requests

2 participants