|
| 1 | +:github: https://github.com/elastic/elasticsearch-net |
| 2 | + |
| 3 | +[[breaking-changes]] |
| 4 | +== Breaking Changes |
| 5 | + |
| 6 | +[float] |
| 7 | +== Elasticsearch 1.0 |
| 8 | + |
| 9 | +Elasticsearch 1.0 comes with it's own set of breaking changes which |
| 10 | +http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/breaking-changes.html[are all documented in the elasticsearch documentation]. |
| 11 | +This page describes breaking changes NEST introduces in its 1.0 release and to an extend how you should |
| 12 | +handle Elasticsearch 1.0 changes in your exisiting code base using NEST prior to NEST 1.0. |
| 13 | + |
| 14 | +[float] |
| 15 | +== NEST 1.0 |
| 16 | + |
| 17 | +=== Strong Named Packages |
| 18 | + |
| 19 | +Prior to 1.0 NEST came with a `NEST` and `NEST.Signed` nuget package. |
| 20 | +In 1.0 there is one package called `NEST` which is a signed strong named assembly. |
| 21 | +We follow the example of JSON.NET and only change our `AssemblyVersion` on major releases only |
| 22 | +update the `AssemblyFileVersion` for every release. This way you get most of the benefits of unsigned |
| 23 | +assemblies while still providing support for developers whose business guidelines mandates the usage of signed assemblies. |
| 24 | + |
| 25 | +=== IElasticClient |
| 26 | + |
| 27 | +The outer layer of NEST has been completely rewritten from scratch. |
| 28 | +Many calls will now have a different signature. Although the most common ones have been |
| 29 | +reimplemented as {github}/tree/1.x/src/Nest/ConvenienceExtensions[extensions methods]. |
| 30 | +Two notable changes should be outlined though. |
| 31 | + |
| 32 | +=== Renamed Get() to Source(), Removed GetFull() |
| 33 | + |
| 34 | +When Martijn first wrote NEST back in 2010, he thought it would be handy if the Get() operation |
| 35 | +returned only the document, and if you wanted the full enveloped Elasticsearch response, you'd use `GetFull()`. |
| 36 | +This was rather confusing and on top of that Elasticsearch 1.0 now has it's own endpoint for getting JUST the document `_source`. |
| 37 | +Similarily `GetMany()` is now called `SourceMany()`. |
| 38 | + |
| 39 | +=== Renamed QueryResponse to SearchResponse |
| 40 | + |
| 41 | +The fact that `client.Search<T>()` returns a `QueryResponse<T>` and not a `SearchResponse<T>` never felt right, |
| 42 | +NEST 1.0 therefore renamed `QueryResponse<T>` to `SearchResponse<T>` |
| 43 | + |
| 44 | +=== Renamed PutTemplateRaw() |
| 45 | + |
| 46 | +to `.PutTemplate` and can be used as follows: |
| 47 | + |
| 48 | +[source,csharp] |
| 49 | +---- |
| 50 | +client.PutTemplate("template_name", s => s.Template("template_body")); |
| 51 | +---- |
| 52 | + |
| 53 | +=== Other Renames |
| 54 | + |
| 55 | +* `RootObjectMappingDescriptor` => `PutMappingDescriptor<T>` |
| 56 | +* `BaseFilter` => `FilterContainer` |
| 57 | +* `BaseQuery` => `QueryContainer` |
| 58 | +* `SortDescriptor` => `SortFieldDescriptor` |
| 59 | + |
| 60 | +=== Removed IResponse.Error |
| 61 | + |
| 62 | +`IResponse.Error.Exception` no longer exists, it is inlined to `IResponse.OriginalException`. |
| 63 | +The Error property did not hold any information that was not available on IResponse.ConnectionStatus. |
| 64 | + |
| 65 | +=== Removed IndexMany() |
| 66 | + |
| 67 | +`IndexMany` no longer has an overload that takes `SimpleBulkParameters`. |
| 68 | +You are now required to use `Bulk()` directly if you need more fine grained control. |
| 69 | + |
| 70 | +=== Removed MapFromAttributes() |
| 71 | + |
| 72 | +Attributes are too limited in what they can specify, so `[ElasticType()]` can now only specify the type name and the id property. |
| 73 | +All the other annotations have been removed from `[ElasticType()]`. The properties on `[ElasticProperty()]` still exist and can be applied like this: |
| 74 | + |
| 75 | +[source,csharp] |
| 76 | +---- |
| 77 | +var x = this._client.CreateIndex(index, s => s |
| 78 | + .AddMapping<ElasticsearchProject>(m => m |
| 79 | + .MapFromAttributes() |
| 80 | + .DateDetection() |
| 81 | + .IndexAnalyzer()) |
| 82 | +); |
| 83 | +---- |
| 84 | + |
| 85 | +Or in a separate put mapping call: |
| 86 | + |
| 87 | +[source,csharp] |
| 88 | +---- |
| 89 | +var response = client.Map<ElasticsearchProject>(m => m.MapFromAttributes()......); |
| 90 | +---- |
| 91 | + |
| 92 | +=== Response Shortcuts |
| 93 | + |
| 94 | +Prior to 1.0, some calls directly returned a bool or value instead of the full enveloped Elasticsearch response. |
| 95 | + |
| 96 | +i.e `client.IndexExists("myIndexName")` used to return a bool but should now be called like this: |
| 97 | + |
| 98 | +[source,csharp] |
| 99 | +---- |
| 100 | +client.IndexExists(i => i.Index("myIndexName")).Exists |
| 101 | +---- |
| 102 | + |
| 103 | +=== Alias Helpers |
| 104 | + |
| 105 | +NEST 0.12.0 had some alias helpers, `SwapAlias()`, `GetIndicesPointingToAlias()`, etc. These have been removed in favor of just `Alias()` and `GetAliases()`. |
| 106 | + |
| 107 | +=== Fields() vs SourceInclude() |
| 108 | + |
| 109 | +Prior to Elasticsearch 1.0, you could specify to return only certain fields and they would return like this: |
| 110 | + |
| 111 | +[source,javascript] |
| 112 | +---- |
| 113 | +{ |
| 114 | + "fields" : { |
| 115 | + "name": "NEST", |
| 116 | + "followers.firstName": ["Martijn", "John"] |
| 117 | + } |
| 118 | +} |
| 119 | +---- |
| 120 | + |
| 121 | +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. |
| 122 | + |
| 123 | +[source,javascript] |
| 124 | +---- |
| 125 | +{ |
| 126 | + "fields" : { |
| 127 | + "name": ["NEST"], |
| 128 | + "followers.firstName": ["Martijn", "John"] |
| 129 | + } |
| 130 | +} |
| 131 | +---- |
| 132 | + |
| 133 | +Previously, Documents was a collection of `T` with just the specified fields filled in, |
| 134 | +other fields would be ``null or have their default value. Now, Documents is an empty collection. |
| 135 | + |
| 136 | +Previously, `DocumentsWithMetaData` -> `Fields` would be an instance of ``T with just the specified fields filled in, |
| 137 | +other fields would be null or have their default value. |
| 138 | +Now, `Hits -> Fields` is (backed by) a dictionary containing only the specified fields. |
| 139 | + |
| 140 | +NEST 1.0 still supports fields, but is now a bit more verbose in how it supports mapping the fields back: |
| 141 | + |
| 142 | +[source,csharp] |
| 143 | +---- |
| 144 | +var fields = _client.Get<DTO>(g => g |
| 145 | + .Id(4) |
| 146 | + .Fields(f => f.Name, f => f.Followers.First().FirstName) |
| 147 | +).Fields; |
| 148 | +
|
| 149 | +var name = fields.FieldValue<DTO, string>(f => f.Name); |
| 150 | +var list = fields.FieldValue<DTO, string>(f => f.Followers[0].FirstName); |
| 151 | +---- |
| 152 | + |
| 153 | +`name` and `list` are of type `string[]` |
| 154 | + |
| 155 | +=== DocumentsWithMetaData |
| 156 | + |
| 157 | +When you do a search with NEST 0.12, you'd get back a `QueryResponse<T>` with two ways to loop over your results. |
| 158 | +`.Documents` is an `IEnumerable<T>` and `.DocumentsWithMetaData` is and `IEnumerable<IHit<T>>` depending on your needs one of them might be easier to use. |
| 159 | + |
| 160 | +Starting from NEST 1.0 `.DocumentsWithMetaData` is now called simply `.Hits`. |
| 161 | + |
| 162 | +The old `.Hits` has been renamed to `HitsMetaData`. |
| 163 | + |
| 164 | +=== int Properties |
| 165 | + |
| 166 | +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. |
| 167 | + |
| 168 | +[float] |
| 169 | +== Found another breaking change? |
| 170 | + |
| 171 | +If you found another breaking chage please let us know on {github}/issues[the github issues]. |
| 172 | + |
0 commit comments