我正在使用Nest 6.2和ES 6.6
我有以下代码运行正常:
var response = elasticClient.Search< PropertyRecord>(s => s .Query(q => q.Terms( …
你可以获得JSON 任何 NEST请求使用 SerializeToString 扩展方法
SerializeToString
var client = new ElasticClient(); var listOfPropertyIds = new [] { 1, 2, 3 }; // pull the descriptor out of the client API call var searchDescriptor = new SearchDescriptor<PropertyRecord>() .Query(q => q.Terms( c => c .Field(f => f.property_id_orig) .Terms(listOfPropertyIds) // a list of 20 ids say... )) .From(0) .Take(100); var json = client.RequestResponseSerializer.SerializeToString(searchDescriptor, SerializationFormatting.Indented); Console.WriteLine(json);
产量
{ "from": 0, "query": { "terms": { "property_id_orig": [ 1, 2, 3 ] } }, "size": 100 }