Searching ElasticSearch using NEST C# Client

前端 未结 4 1184
-上瘾入骨i
-上瘾入骨i 2021-02-06 10:37

I started looking around for a search engine and after some reading I decided going with ElasticSearch (which is quite amazing :)), my project is in C# so I looked around for a

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 11:25

    With ElasticSearch 2.0, I have to use a SearchResponse< NewType > in the Search method like this :

    var json = JsonConvert.SerializeObject(searchQuery);
    var body = new PostData(json);
    var res = _elasticClient.Search>(body);
    IEnumerable result = res.Body.Hits.Select(h => h.Source).ToList();
    
    
    

    Hope it help.

    Note: I found very few documentation about PostData class and its generic type parameter

    提交回复
    热议问题