我正在使用NEST来获得一些聚合工作,但我总是得到的是#34;值不能为null。参数名称:键"
我更新了查询
你能帮帮我吗。
代码:
var agg = esclient.Search<Artifact>(s => s.Aggregations(ag => ag
.Filter("refineSearch", fi => fi.Filter(fl => fl.Bool(b => b
.Should(sh => sh.Terms("multimediaReferenceList.mimeType", input.Filters.Media)
&& sh.Terms("physicalLocations.level1", input.Filters.Location)
&& sh.Terms("objectCategory", input.Filters.Type)
&& sh.Range(r => r.GreaterOrEquals(input.Years[0]).OnField(of => of.MinYear))
&& sh.Range(ra => ra.LowerOrEquals(input.Years[1]).OnField(od => od.MaxYear)))))
.Aggregations(aa => aa
.Terms("type", att => att.Field("objectCategory"))
.Terms("media", att => att.Field("multimediaReferenceList.mimeType"))
.Terms("location", att => att.Field("physicalLocations.level1"))))));
堆栈追踪:
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Nest.Resolvers.Converters.Aggregations.AggregationConverter.GetNestedAggregations(JsonReader reader, JsonSerializer serializer)
at Nest.Resolvers.Converters.Aggregations.AggregationConverter.GetSingleBucketAggregation(JsonReader reader, JsonSerializer serializer)
at Nest.Resolvers.Converters.Aggregations.AggregationConverter.ReadAggregation(JsonReader reader, JsonSerializer serializer)
at Nest.Resolvers.Converters.Aggregations.AggregationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Nest.NestSerializer.DeserializeUsingSettings[T](Stream stream, JsonSerializerSettings settings)
at Nest.NestSerializer.Deserialize[T](Stream stream)
at Nest.NestSerializer.DeserializeInternal[T](Stream stream, JsonConverter converter)
at Nest.ElasticClient.FieldsSearchDeserializer[T,TResult](IElasticsearchResponse response, Stream stream, ISearchRequest d)
at Nest.ElasticClient.<>c__DisplayClass1f9`2.<CreateSearchDeserializer>b__1f8(IElasticsearchResponse r, Stream s)
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.StreamToTypedResponse[T](ElasticsearchResponse`1 streamResponse, ITransportRequestState requestState, Byte[] readBytes)
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.ReturnTypedResponse[T](TransportRequestState`1 requestState, ElasticsearchResponse`1 streamResponse, ElasticsearchServerError& error)
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.CoordinateRequest[T](TransportRequestState`1 requestState, Int32 maxRetries, Int32 retried, Boolean& aliveResponse)
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.DoRequest[T](TransportRequestState`1 requestState)
at Elasticsearch.Net.Connection.RequestHandlers.RequestHandler.Request[T](TransportRequestState`1 requestState, Object data)
at Elasticsearch.Net.Connection.Transport.DoRequest[T](String method, String path, Object data, IRequestParameters requestParameters)
at Elasticsearch.Net.ElasticsearchClient.Search[T](Object body, Func`2 requestParameters)
at Nest.ElasticClient.Search[T,TResult](Func`2 searchSelector)
at THF.CMS.Api.SearchManager.GetSearchResults(SearchRequest input) in c:\inetpub\wwwroot\SearchManager.cs:line 71
答案 0 :(得分:0)
您尝试使用Dictionary
在null
中搜索密钥,即:
Dictionary<DataType, AlsoDataType> dict = new Dictionary<DataType, AlsoDataType>();
DataType key = null;
Console.WriteLine(dict[key].ToString()); // <-------- key is null