Upgrading NEST 1 to 2
Breaking1.9.2 โ 2.5.8Breaking20Platform1Deprecated12New60Changed43Fixed127Other12
BreakingUpgrade verdict
18 breaking changes and a platform requirement change.
In plain terms
- When a document is missing, get and delete calls no longer report an invalid response; instead they succeed and you must check whether the document was found.
- Removes `RethrowKeepingStackTrace` in favour of simply `throw`ing the exception.
- The low-level client interface has a new name, so code referring to the old name must be updated.
- Update now supports fields and is no longer generic.
Must act Top 5 of 31 that need code or config changes
Requires Target frameworks .NETFramework4.5, .NETFramework4.6, .NETStandard1.3 from 2.4.0 (none stated before).
Adds netstandard.library 1.6.0, system.collections.specialized 4.3.0, system.linq.queryable 4.0.1, system.reflection.typeextensions 4.3.0.
Moves elasticsearch.net [1.9.2, 2.0) โ [2.5.8, 3.0.0), newtonsoft.json [9.0, 10.0) โ [11.0.1, 12.0.0). Your build may pick other versions.
What you must change
Breaking18
404s on Get<T>() and Delete<T>() (and async variants) now return .IsValid as true and deserialize the response, setting .Found.
Get<T>()Delete<T>().IsValid.FoundRemoves
RethrowKeepingStackTrace in favour of simply throwing the exception.RethrowKeepingStackTraceRenames IElasticsearchClient to IElasticLowLevelClient to better specify intent.
IElasticsearchClientIElasticLowLevelClientUpdate now supports fields and is no longer generic.
UpdateRenames ConnectionStatusHandler to OnRequestCompleted and restores its functionality.
ConnectionStatusHandlerOnRequestCompletedRemoves filter constructs from the code base to reflect the removal of filters in Elasticsearch 2.0.
Splits ElasticPropertyAttribute into individual per-type attributes and renames ElasticTypeAttribute to ElasticsearchTypeAttribute.
ElasticPropertyAttributeElasticTypeAttributeElasticsearchTypeAttributeStringDateNumberNestedElasticTypeMoves Analyze API parameters from the query string to the request body.
AnalyzeRewrites NEST internals, replacing TPL-based code with async/await and reworking exception and error handling.
Replaces many NEST 1.x exception types with deterministic ElasticsearchClientException, UnexpectedElasticsearchClientException and CLR runtime exceptions.
MaxRetryExceptionElasticsearchAuthExceptionElasticsearchServerExceptionDslExceptionIConnectionPoolElasticsearchClientExceptionUnexpectedElasticsearchClientExceptionMerges query and filter constructs into queries, renaming filters such as AndFilter to AndQuery.
AndFilterAndQueryRequires descending into isolated descriptors, for example Search().Sort(ss=>ss...) instead of SortAscending and SortScript on Search().
Search()SortAscending()SortScript()Sort()Field()Script()Ascending()GeoDistance()Replaces ElasticPropertyAttribute with type-specific attributes such as ElasticsearchType, String, Date, Number and Nested.
ElasticsearchTypeElasticsearchType.NameElasticsearchType.IdPropertyStringDateNumberNestedElasticPropertyAttributeChanges many string or primitive parameters to strongly typed objects such as Id, Field, Fields, Index, Indices, Type, Types and DocumentPath<T>.
IdFieldFieldsIndexIndicesTypeTypesDocumentPath<T>High level methods now take Time instead of TimeSpan.
TimeTimeSpanReplaces ThrowOnElasticsearchServerExceptions() with ThrowExceptions() to control whether the client throws exceptions.
ThrowOnElasticsearchServerExceptions()ThrowExceptions()Reduces the exception types the client throws to ElasticsearchClientException, UnexpectedElasticsearchClientException, and development time CLR exceptions.
ElasticsearchClientExceptionUnexpectedElasticsearchClientExceptionIntroduces many breaking changes in NEST 2.0 and revalidates request and response domain objects against Elasticsearch 2.0.
Platform1
NEST 2.0.0-alpha1 supports only .NET 4.5 and up; PCL/.NET Core support is not yet part of the build and CI.
Deprecations to plan for
Deprecated12
Introduces EndOffset on AnalyzeToken and deprecates the misspelt EndPostion.
AnalyzeTokenEndOffsetEndPostionMarks IsValid obsolete for Get and Delete responses to warn about the behavioural change in #2637.
IsValidMarks type level analyzers as obsolete; they will be removed in Elasticsearch 6.0.
Introduces TookAsLong for the Took value, caps Took at int.MaxValue, and marks Took Obsolete.
TookTookAsLongMarks properties removed in 5.0 with ObsoleteAttribute.
ObsoleteAttributeMarks MissingQuery with ObsoleteAttribute as removed in 5.0.
MissingQueryObsoleteAttributeMarks IndexName on property mappings with ObsoleteAttribute as removed in 5.0.
IndexNameObsoleteAttributeMarks .Highlights on SearchResponse<T> as obsolete, to be removed in 5.x.
SearchResponse<T>.HighlightsHitsMetaData.HitsDeprecates Alias on GetAlias() in favour of Name.
GetAlias()AliasNameDeprecates the misnamed Field() method on SuggestContextDescriptor in favor of Path().
SuggestContextDescriptor.Field()SuggestContextDescriptor.Path()Deprecates factor on DateHistogramAggregation.
factorDateHistogramAggregationMappings: Marks PositionOffsetGap as obsolete in favor of PositionIncrementGap.
PositionOffsetGapPositionIncrementGap