|
| 1 | +--- |
| 2 | +template: layout.jade |
| 3 | +title: Breaking changes |
| 4 | +menusection: concepts |
| 5 | +menuitem: breaking-changes |
| 6 | +--- |
| 7 | + |
| 8 | +#Breaking changes |
| 9 | + |
| 10 | +## Elasticsearch 1.0 |
| 11 | + |
| 12 | +Elasticsearch 1.0 comes with it's own set of breaking changes which [are all documented in the elasticsearch documentation](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/breaking-changes.html). This page describes breaking changes NEST introduces in its 1.0 release and to an extend how you should handle Elasticsearch 1.0 changes in your exisiting code base using NEST prior to NEST 1.0. |
| 13 | + |
| 14 | +## NEST 1.0 |
| 15 | + |
| 16 | +### Strong named packages |
| 17 | + |
| 18 | +Prior to 1.0 NEST came with a `NEST` and `NEST.Signed` nuget package. In 1.0 there is one package called `NEST` which is a signed strong named assembly. We follow the example of JSON.NET and only change our `AssemblyVersion` on major releases only update the `AssemblyFileVersion` for every release. This way you get most of the benefits of unsigned assemblies while still providing support for developers who's business guidelines mandates the usage of signed assemblies. |
| 19 | + |
| 20 | + |
| 21 | +### IElasticClient |
| 22 | + |
| 23 | +The outer layer of NEST has been completely rewritten from scratch. Many calls will now have a different signature. Although the most common ones have been reimplemented as [extensions methods](http://github.com/elasticsearch/elasticsearch-net/tree/master/src/Nest/ConvenienceExtensions). Two notable changes should be outlined though. |
| 24 | + |
| 25 | +#### Get() is now called Source() |
| 26 | +When I first wrote NEST back in 2010 I though it would be handy if the Get() operation returned only the document and if you want the full envelopped elasticsearch response you'd use `GetFull()`. This was rather confusing and on top of that Elasticsearch 1.0 now has it's own endpoint for getting JUST the document `_source`. |
| 27 | +Similarily `GetMany()` is now called `SourceMany()`. |
| 28 | + |
| 29 | +### Renamed QueryResponse to SearchResponse |
| 30 | + |
| 31 | +The fact that `client.Search<T>()` returns a `QueryResponse<T>` and not a `SearchResponse<T>` never felt right to me, NEST 1.0 therefor renamed `QueryResponse<T>` to `SearchResponse<T>` |
| 32 | + |
| 33 | +#### Alias helpers |
| 34 | + |
| 35 | +NEST 0.12.0 had some alias helpers, `SwapAlias()`, `GetIndicesPointingToAlias()` these have been removed in favor of just `Alias()` and `GetAliases()`. Especially the later could benefit from some extension methods that make the common use cases a bit easier to program with. These did not make the beta release. |
| 36 | + |
| 37 | +#### Fields() vs SourceInclude() |
| 38 | + |
| 39 | +Prior to Elasticsearch you could specify to return only certain fields and they would return like this: |
| 40 | + |
| 41 | + ... |
| 42 | + "fields" { |
| 43 | + "name" : "NEST" |
| 44 | + "followers.firstName: ["Martijn", "John", ...] |
| 45 | + } |
| 46 | + ... |
| 47 | + |
| 48 | +In many case this could be mapped to the type of DTO you give search (i.e in `.Search<DTO>()`). Elasticsearch 1.0 now always returns the fields as arrays. |
| 49 | + |
| 50 | + ... |
| 51 | + "fields" { |
| 52 | + "name" : ["NEST"] |
| 53 | + "followers.firstName: ["Martijn", "John", ...] |
| 54 | + } |
| 55 | + ... |
| 56 | + |
| 57 | +NEST 1.0 still supports this but is now a bit more verbose in how it supports mapping the fields back: |
| 58 | + |
| 59 | + |
| 60 | + var fields = _client.Get<DTO>(g => g |
| 61 | + .Id(4) |
| 62 | + .Fields(f => f.Name, f => f.Followers.First().FirstName) |
| 63 | + ).Fields; |
| 64 | + var name = fields.FieldValue<DTO, string>(f => f.Name); |
| 65 | + var list = fields.FieldValue<DTO, string>(f=>f.Followers[0].FirstName); |
| 66 | + |
| 67 | +`name` and `list` are of type `string[]` |
| 68 | + |
| 69 | +### DocumentsWithMetaData |
| 70 | + |
| 71 | +When you do a search with NEST 0.12 you'd get back a `QueryResponse<T>` with two ways to loop over your results. `.Documents` is an `IEnumerable<T>` and `.DocumentsWithMetaData` is and `IEnumerable<IHit<T>>` depending on your needs one of them might be easier to use. |
| 72 | + |
| 73 | +Starting from NEST 1.0 `.DocumentsWithMetaData` is now called simply `.Hits`. |
| 74 | + |
| 75 | +### int Properties |
| 76 | + |
| 77 | +In quite a few places values that should have been `long` were mapped as `int` in NEST 0.12.0 which could be troublesome if you for instance have more than `2,147,483,647` matching documents. In my preperations for this release I helped port one of my former employees applications to Elasticsearch 1.1 and NEST 1.0 and found that this change had the most impact on the application and all of its models. |
| 78 | + |
| 79 | +# Found another breaking change? |
| 80 | + |
| 81 | +If you found another breaking chage please let us know on [the github issues](http://www.github.com/elasticsearch/elasticsearch-net/issues) |
| 82 | + |
0 commit comments