NET-Client 8.19: Serialisation of QueryDescriptor<T>

Hi there,

I have another question regarding serialisation. After updating to version 8.19.4, serialisation of QueryDescriptor does not work as before.

“Serialization in version 9.0 has been completely overhauled” which could mean that in corresponding version 8.19.0 it has the same behavior.

Example:

QueryDescriptor<Object> queryDescriptor = new QueryDescriptor<Object>(new Query());
queryDescriptor = queryDescriptor.MatchAll();
ElasticsearchClient client = new ElasticsearchClient(new ElasticsearchClientSettings());
String queryString = client.ElasticsearchClientSettings.RequestResponseSerializer.SerializeToString(queryDescriptor);

queryString: {}

This worked with 8.18 so I guess something has changed. Can I achieve to serialise QueryDescriptor like before or is this not supported any more / so far?

Thanks in advance and best regards

Jan

Hi @JanSearch ,

the descriptors do not support direct (de-)serialization in 8.19.x and 9.x.x, but since descriptors do now implement 2-way conversions from/to the corresponding object representation, you could use a cast to fix your code:

client.ElasticsearchClientSettings.RequestResponseSerializer.SerializeToString((Query<Objcet>)queryDescriptor)

Please let me know, if that solves your issue.

Thank you, @flobernd, very much for your fast answer!

It works as promosed (also for AggregationDescriptor and SortOptionsDescriptor)!

Best regards

Jan

1 Like