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
Description of the problem including expected versus actual behavior: Esql.QueryAsObjectsAsync<TDocument> throws a serialization exception: The element cannot be an object or array, if TDocument contains an array.
using Elastic.Clients.Elasticsearch;
var searchClient = new ElasticsearchClient(
new ElasticsearchClientSettings(new Uri("http://localhost:9200")).DefaultMappingFor<Person>(c =>
c.IndexName("persons")
)
);
if ((await searchClient.Indices.ExistsAsync<Person>()).Exists)
{
await searchClient.Indices.DeleteAsync<Person>();
}
var createResp = await searchClient.Indices.CreateAsync<Person>();
var indexRes = await searchClient.IndexAsync(new Person { Id = 0, Values = [1, 2, 3] });
Thread.Sleep(5000);
var result = await searchClient.Esql.QueryAsObjectsAsync<Person>(q => q.Query("FROM persons"));
foreach (var item in result.ToArray())
{
Console.WriteLine(item.Id);
}
public class Person
{
public int Id { get; set; }
public int[] Values { get; set; } = [];
}
Exception is thrown
Exception has occurred: CLR/System.InvalidOperationException
An exception of type 'System.InvalidOperationException' occurred in System.Text.Json.dll but was not handled in user code: 'The element cannot be an object or array.
Expected behavior
The response from Esql.QueryAsObjects<TDocument> should successfully map to type Person.
The text was updated successfully, but these errors were encountered:
AlexanderEklf
changed the title
Esql.QueryAsObjectsAsync<TDocument>` throws a serialization exception: The element cannot be an object or array, if TDocument contains an array
Esql.QueryAsObjectsAsync<TDocument> throws a serialization exception: The element cannot be an object or array, if TDocument contains an array
Feb 7, 2025
Elastic.Clients.Elasticsearch version: 8.17.1
Elasticsearch version: 8.17.1
.NET runtime version: 9
Operating system version: Windows 11
Description of the problem including expected versus actual behavior:
Esql.QueryAsObjectsAsync<TDocument>
throws a serialization exception: The element cannot be an object or array, if TDocument contains an array.Steps to reproduce:
Expected behavior
The response from
Esql.QueryAsObjects<TDocument>
should successfully map to type Person.The text was updated successfully, but these errors were encountered: