Mpdreamz/NEST — pull request #349 by Mpdreamz (2013-09-20 19:53:55+00:00)
Title: Getting rid of some of the hairy parts in NEST part 1/2

NEST is pretty old the first commit was in 2010! 2010-10-07T09:32:05-07:00 to be exact, thats only 8 months after elasticsearch's first commit 2010-02-08T05:22:27-08:00 for those who are wandering.

This PR is about getting rid of some of the fluff gathered in the past three years.

### Serialization

Back when NEST first started serializing JSON.NET left dictionary keys alone but in between version 4.0r1 and 4.0r2 of Json.NET this changed (for more info see: http://json.codeplex.com/workitem/20923)

At the time I "solved" this by having two serializers one that does camelCasing and one that doesn't. This was a **bad bad** mistake on my part as it created a very confusing codebase as to when to use which serializationsettings.

This PR finally rectifies this and introduces `ElasticSerializer` with only one `Serialize` and one `Deserialize` method.

Because of this we can now write this:

```C#
var connectionStatus = this._client.Raw.SearchPost(index, typeName, query);
return connectionStatus.ToParsedResponse>();
```

or go even more low level:

```C#
var connectionStatus = this._client.Connection.PostSync("/myindex/mytype", "{}");
return connectionStatus.ToParsedResponse>();
```

### RawClient

Not technically part of this commit as i already pushed it to master but the past example shows how NEST will now seperate the Raw calls to elastic search using a .Raw property which exposes a IRawElasticClient (which you can ofcourse `new` as well if thats all you need`.

The cool thing is that this rawclient is automatically generated from scanning all the REST endpoints in the elasticsearch source code so it should be fairly easy to keep it up to date.

This means that all the `*Raw()` methods on `IElasticClient` are now gone.

### Property name handling

You can now finally hook into how NEST should handle unspecified propertynames, meaning those not marked with an `[ElasticProperty(Name="")]` or `(I)Dictionary` properties who should be treated verbatim by calling:

```
//Do not do anything to properties
.SetDefaultPropertyNameInferrer(a=>a)
```

On `ConnectionSettings`.

## Next up: (AKA part 2)

Not part of this PR but serves as a heads up of coming changes

### PathResolver

This class is used to make all the url endpoints, since we have IRawClient now which already has all the urls in it this class needs to go. Instead descriptors should be responsible for returning the querystring parameters.

All the calls on IElasticClient should then use the IRawClient instead of going directly to IConnection.

### Missing Async Methods on IElasticClient

Not all the methods on IElasticClient have an Async counterpart.