Elasticsearch.Net, strange deserialization after .Index

Hi,

(let me know if this is not the right place to post ElasticSearch.Net
questions).

I'm indexing a document of type "User" through ElasticSearch.Net with this
command (key is a string guid):

client.Index(index, "user", key, user);

This invokes the serializer and stores the json in my ES cluster, as
expected. ElasticSearch responds with this json:

{
"_index":"users_2014_09","_type":"user","_id":"M8k_6WLTtESlYod8-CDUXw_P4wXE0OkkvprjRiqGP1bqQ","_version":1,"created":true}

Now the strange thing is that the ElasticSearch.Net client tries to
deserialize this result as a "User" object. Normally this deserialization
method will return null and not create any visible side-effects, but in my
case I'm using the field "created" as a DateTime field, and the
deserialization throws a nasty error.

My question is: Why on earth does the client spend energy deserializing a
response to an Index command, and into the wrong type? This looks like a
bug.

Thanks,
Lasse

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1bfff890-ae3d-422f-b12b-54548cf01f62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

This is probably a bug of the .NET client API, and you should log it on
github where they monitor issues for it

You might find this alternative library useful:
https://github.com/synhershko/NElasticsearch available from nuget as well
https://www.nuget.org/packages/NElasticsearch/

--

Itamar Syn-Hershko
http://code972.com | @synhershko https://twitter.com/synhershko
Freelance Developer & Consultant
Author of RavenDB in Action http://manning.com/synhershko/

On Tue, Sep 16, 2014 at 5:43 PM, Lasse Schou lasseschou@gmail.com wrote:

Hi,

(let me know if this is not the right place to post ElasticSearch.Net
questions).

I'm indexing a document of type "User" through ElasticSearch.Net with this
command (key is a string guid):

client.Index(index, "user", key, user);

This invokes the serializer and stores the json in my ES cluster, as
expected. ElasticSearch responds with this json:

{
"_index":"users_2014_09","_type":"user","_id":"M8k_6WLTtESlYod8-CDUXw_P4wXE0OkkvprjRiqGP1bqQ","_version":1,"created":true}

Now the strange thing is that the ElasticSearch.Net client tries to
deserialize this result as a "User" object. Normally this deserialization
method will return null and not create any visible side-effects, but in my
case I'm using the field "created" as a DateTime field, and the
deserialization throws a nasty error.

My question is: Why on earth does the client spend energy deserializing a
response to an Index command, and into the wrong type? This looks like a
bug.

Thanks,
Lasse

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1bfff890-ae3d-422f-b12b-54548cf01f62%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/1bfff890-ae3d-422f-b12b-54548cf01f62%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHTr4ZtJwbts5%2BTCCYE-dkPLzDTG8ZQjazUEcYeZxh9ePc08JQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

This is because when using Elasticsearch.NET, specifying the type like that is actually specifying what type the expected response should be serialized into, rather than the type of object you're sending to Elasticsearch.

Drop the type completely and client.Index should return a ElasticsearchResponse object type.

See this link for details:
http://nest.azurewebsites.net/elasticsearch-net/handling-responses.html

Hope this helps.