-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An item with the same key has already been added (ElasticSearch.NET 1.6.0 vs Newtonsoft.Json 7.0.1) #1462
Comments
It looks like reverting to Newtonsoft.Json 6.0.8 fixes this issue, is it something that you can reproduce? |
Hey @SalvatoreMeschini NEST is currently on Newtonsoft.Json 6.0.1, and we don't support or run any tests against 7.x yet, so there could very well be some issues. Out of curiosity, how did you get 7.0.1? Did your application already contain a reference to it, or did it somehow get installed when you installed NEST? |
I got the same issue. I think it's the same as #1464 This fails too with the same deserialization issues.
|
@wbsimms Okay so just to be clear, this isn't the same issue as #1464. So you also upgaded to Json.NET 7.x? NEST doesn't currently support Json.NET 7.x...you will certainly run into this issue if you upgrade. I've just tested this myself and hit this exception as well. We'll add support for the latest Json.NET in a future release, but for now you'll have to stay on 6.0.1. |
Got it. Thanks! Keep up the awesome work! |
FYI working on upgrading to Json.NET 7 here: https://github.com/elastic/elasticsearch-net/tree/fix/update-jsonnet |
@gmarz I updated all packages, including NewtonSoft JSON as ElasticSearch.NET+NEST require JSON >= 6.0.1 (but not < 7.0.1 :) ). By the way, issues are actually solved by downgrading to 6.0.8 To answer your question: I already had the JSON package because of another dependency. Thanks! |
Thanks for the additional info @SalvatoreMeschini. NEST will be using the latest Json.NET 7.0.1 and this issue will be fixed once #1465 is merged. |
Closed via #1465 |
I updated both Nest packages and ElasticSearch server to latest versions, but now the code is broken.
This line (I simply recompiled the project after updating the packages via NuGet, I'm using Newtonsoft.Json 7.0.1):
ISearchResponse response = _client.Search(s => s.From(0).Size(limit).QueryString(searchString));
Now is leading to:
ERROR 2015-06-23 10:47:14,675 [11 ] .Mvc.Controllers.AbpHandleErrorAttribute - System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary
2.Insert(TKey key, TValue value, Boolean add) at System.Collections.ObjectModel.KeyedCollection
2.AddKey(TKey key, TItem item)at System.Collections.ObjectModel.KeyedCollection
2.InsertItem(Int32 index, TItem item) at System.Collections.ObjectModel.Collection
1.Add(T item)at Newtonsoft.Json.Utilities.CollectionUtils.AddRange[T](IList
1 initial, IEnumerable
1 collection)at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
at Nest.Resolvers.ElasticContractResolver.CreateContract(Type objectType) in c:\code\elasticsearch-net\src\Nest\Resolvers\ElasticContractResolver.cs:line 29
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
at Nest.Resolvers.SettingsContractResolver.ResolveContract(Type type) in c:\code\elasticsearch-net\src\Nest\Resolvers\SettingsContractResolver.cs:line 34
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe(Object value)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Type type, Formatting formatting, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value, Formatting formatting, JsonSerializerSettings settings)
at Nest.NestSerializer.Serialize(Object data, SerializationFormatting formatting) in c:\code\elasticsearch-net\src\Nest\ExposedInternals\NestSerializer.cs:line 30
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandlerBase.PostData(Object data) in c:\code\elasticsearch-net\src\Elasticsearch.Net\Connection\RequestHandlers\RequestHandlerBase.cs:line 66
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.Request[T](TransportRequestState
1 requestState, Object data) in c:\code\elasticsearch-net\src\Elasticsearch.Net\Connection\RequestHandlers\RequestHandler.cs:line 31 at Elasticsearch.Net.Connection.Transport.DoRequest[T](String method, String path, Object data, IRequestParameters requestParameters) in c:\code\elasticsearch-net\src\Elasticsearch.Net\Connection\Transport.cs:line 343 at Elasticsearch.Net.ElasticsearchClient.DoRequest[T](String method, String path, Object data, IRequestParameters requestParameters) in c:\code\elasticsearch-net\src\Elasticsearch.Net\ElasticsearchClient.cs:line 65 at Elasticsearch.Net.ElasticsearchClient.Search[T](String index, String type, Object body, Func
2 requestParameters) in c:\code\elasticsearch-net\src\Elasticsearch.Net\ElasticsearchClient.Generated.cs:line 34635at Nest.RawDispatch.SearchDispatch[T](ElasticsearchPathInfo
1 pathInfo, Object body) in c:\code\elasticsearch-net\src\Nest\RawDispatch.generated.cs:line 3624 at Nest.ElasticClient.Search[T,TResult](Func
2 searchSelector) in c:\code\elasticsearch-net\src\Nest\ElasticClient-Search.cs:line 32at Nest.ElasticClient.Search[T](Func`2 searchSelector) in c:\code\elasticsearch-net\src\Nest\ElasticClient-Search.cs:line 16
at KB.FTS.FTSSearchProvider.SearchETKD(String searchString, Int32 limit) in c:\Projects\KnowledgeBase\KB\KB.Core\FTS\FTSSearchProvider.cs:line 62
The text was updated successfully, but these errors were encountered: