Search code examples
c#.netelasticsearchnest.net-4.8

Elastic Client Search<T> method parsing problem


I use the Search method in the Elastic Client. If I give it as a search, I can pull data from Elastic. However, if I give it as Search, I can't pull data. All data comes in null. I arranged the inside of the CustomClass as it should be, but no matter what I did, I couldn't pull data from the CustomClass. When I pull it as Search, I can't filter properly. I leave the relevant code example below. Can you help?

This is example code

  var responseOis = this._elasticClient.Search<dynamic>(s => s
                .From(from)
                .Size(size)
                .Sort(k => k.Descending(new Field(sortField)))
                .Index(indexName)
                .Query(q => q.Bool(b => b.Must(mustClauses.ToArray())))
                .Query(q => q.Bool(b => b.MustNot(mustNotClauses.ToArray()))));

Elastic.Client ve Nest version 7.17

Since I thought there was no mapping to the data in the CustomClass, I arranged the fields according to the JSON returned from the elastic. However, it did not happen.


Solution

  • This problem is solved. Problem related to ElasticSearch boolean casting. Before, boolean values are 0 and 1. Then, this value convert true or false and problem is solved. In addition, there are 2 query bool in this code but in this time there is one query bool.