You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aggregations Filters :The JSON value could not be converted to System.Collections.Generic.IReadOnlyCollection`1[Elastic.Clients.Elasticsearch.Aggregations.FiltersBucket]. Path: $.buckets |
#8040
Closed
mike48785601 opened this issue
Feb 16, 2024
· 1 comment
Operating system version:Windows 10 professional edition
Description of the problem including expected versus actual behavior:
Error is happend,and how to fix it.
Steps to reproduce:
public class buy
{
[JsonPropertyName("Id")]
/// <summary>
/// 供求信息编号
/// </summary>
public int BuyId { set; get; }
/// <summary>
/// 用户编号
/// </summary>
///
[JsonPropertyName("Userid")]
public int Userid { set; get; }
/// <summary>
/// 标题
/// </summary>
///
[JsonPropertyName("Title")]
public string Title { set; get; }
[JsonPropertyName("Ischengxin")]
public int Ischengxin { set; get; }
}
var settings = new ElasticsearchClientSettings(new Uri("https://localhost:9200"))
.CertificateFingerprint("9d71addba27bb5efa9e8c45f529f3c9980314106acf62d46672c212c8053e2ee")//8.12 local
.Authentication(new BasicAuthentication("elastic", "xmdC3QQJmkZT5u=AdeOt"))//8.12 local
.DefaultMappingFor(i => i
.IndexName("buyindex")
.IdProperty(s => s.BuyId))
.EnableDebugMode();
var client = new ElasticsearchClient(settings);
TermQuery aaa = new TermQuery("Ischengxin");
aaa.Value = 1;
Query qq = Query.Term(aaa);
var bkt = new Buckets<Query>(new Dictionary<string, Query>
{
{ "chengxin_filter",qq }
}
);
var qr1 = client.Search<buy>(s => s
.Query(q => q
.MatchAll()
)
.Aggregations(a => a
.Filters("f", c => c
.Filters(bkt)
.Aggregations(t => t
.Terms("Userid", ss => ss.Field(f => f.Userid).Aggregations(cc => cc.Max("maxBuyid", avg => avg.Field(p => p.BuyId))))
)
)
)
.Size(3)
.From(0)
);
内部异常 1:
JsonException: The JSON value could not be converted to System.Collections.Generic.IReadOnlyCollection`1[Elastic.Clients.Elasticsearch.Aggregations.FiltersBucket]. Path: $.buckets | LineNumber: 1 | BytePositionInLine: 19.
The text was updated successfully, but these errors were encountered:
Elastic.Clients.Elasticsearch version:8.9.0
Elasticsearch version:8.12.0
.NET runtime version:net6.0
Operating system version:Windows 10 professional edition
Description of the problem including expected versus actual behavior:
Error is happend,and how to fix it.
Steps to reproduce:
var settings = new ElasticsearchClientSettings(new Uri("https://localhost:9200"))
.CertificateFingerprint("9d71addba27bb5efa9e8c45f529f3c9980314106acf62d46672c212c8053e2ee")//8.12 local
.Authentication(new BasicAuthentication("elastic", "xmdC3QQJmkZT5u=AdeOt"))//8.12 local
.DefaultMappingFor(i => i
.IndexName("buyindex")
.IdProperty(s => s.BuyId))
.EnableDebugMode();
var client = new ElasticsearchClient(settings);
Expected behavior
{
"aggregations": {
"f": {
"filters": {
"filters": {
"chengxin_filter": {
"term": {
"Ischengxin": {
"value": 1
}
}
}
}
},
"aggregations": {
"Userid": {
"terms": {
"field": "Userid"
},
"aggregations": {
"maxBuyid": {
"max": {
"field": "Id"
}
}
}
}
}
}
},
"query": {
"match_all": {}
}
}
Provide
DebugInformation
(if relevant):Elastic.Transport.UnexpectedTransportException
HResult=0x80131500
Message=The JSON value could not be converted to System.Collections.Generic.IReadOnlyCollection
1[Elastic.Clients.Elasticsearch.Aggregations.FiltersBucket]. Path: $.buckets | LineNumber: 1 | BytePositionInLine: 19. Source=Elastic.Transport StackTrace: 在 Elastic.Transport.DefaultHttpTransport
1.ThrowUnexpectedTransportException[TResponse](Exception killerException, List1 seenExceptions, RequestData requestData, TResponse response, RequestPipeline pipeline) 在 Elastic.Transport.DefaultHttpTransport
1.Request[TResponse](HttpMethod method, String path, PostData data, RequestParameters requestParameters)在 Elastic.Clients.Elasticsearch.ElasticsearchClient.DoRequest[TRequest,TResponse,TRequestParameters](TRequest request, Action`1 forceConfiguration)
在 es882.Form1.btnbuy_Click(Object sender, EventArgs e) 在 C:\Users\Administrator\source\estest\es882\Form1.cs 中: 第 763 行
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
此异常最初是在此调用堆栈中引发的:
System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(System.Type)
System.Text.Json.Serialization.JsonCollectionConverter<TCollection, TElement>.OnTryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out TCollection)
System.Text.Json.Serialization.JsonConverter.TryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out T)
System.Text.Json.Serialization.Metadata.JsonPropertyInfo.ReadJsonAndSetMember(object, ref System.Text.Json.ReadStack, ref System.Text.Json.Utf8JsonReader)
System.Text.Json.Serialization.Converters.ObjectDefaultConverter.OnTryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out T)
System.Text.Json.Serialization.JsonConverter.TryRead(ref System.Text.Json.Utf8JsonReader, System.Type, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack, out T)
System.Text.Json.Serialization.JsonConverter.ReadCore(ref System.Text.Json.Utf8JsonReader, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack)
System.Text.Json.JsonSerializer.ReadCore(System.Text.Json.Serialization.JsonConverter, ref System.Text.Json.Utf8JsonReader, System.Text.Json.JsonSerializerOptions, ref System.Text.Json.ReadStack)
System.Text.Json.JsonSerializer.Read(ref System.Text.Json.Utf8JsonReader, System.Text.Json.Serialization.Metadata.JsonTypeInfo)
Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadAggregate(ref System.Text.Json.Utf8JsonReader, System.Text.Json.JsonSerializerOptions, System.Collections.Generic.Dictionary<string, Elastic.Clients.Elasticsearch.Aggregations.IAggregate>, string)
...
[调用堆栈已截断]
内部异常 1:
JsonException: The JSON value could not be converted to System.Collections.Generic.IReadOnlyCollection`1[Elastic.Clients.Elasticsearch.Aggregations.FiltersBucket]. Path: $.buckets | LineNumber: 1 | BytePositionInLine: 19.
The text was updated successfully, but these errors were encountered: