NET Client: Serialisation of descriptor objects (e.g. QueryDescriptor)

Dear Elastic forum,

we used NEST so far and are going to switch to the new client.

In NEST it is possible to serialise the descriptor objects, e.g. QueryContainerDescriptor or CreateIndexDescriptor.

In the new NET client I did not find out how to do this, for example for QueryDescriptor. A Query can be serialised to JSON, but not the QueryDescriptor. I use the method ElasticsearchClientSettings.SourceSerializer.Serialize which seems to be the right one.

The reason for serialising queries is that we like to check them in an API before they will be send to Elasticsearch.

I guess that the Elasticsearch client has to serialise these objects. Is it possible that serialisation for descriptor objects does only work internally (inside the client) or am I doing something wrong?

Thanks in advance for any help

Jan

Hi @JanSearch,

which version of the client are you using?

Hi Flobernd,

thank you for your answer!

Currently, I am using the latest version of the 8 client since I try first to switch the client (from NEST 7 to new client 8) and afterwards the server version (from 8 to 9).

Best regards

Jan

The solution is to use

ElasticsearchClient.ElasticsearchClientSettings.RequestResponseSerializer

instead of

ElasticsearchClient.ElasticsearchClientSettings.SourceSerializer!

It offers the extension "SerializeToString" which works as expected with objects like "CreateIndexDescriptor" or "QueryDescriptor".