NEST - Using GET instead of POST/PUT for searching

763 Views Asked by At

Is there a way to tell NEST to use GET instead of POST when performing searches? Similar to how the ElasticSearch documentation shows CURL using GET I'd like to use GET when using NEST instead of using POST as it currently does.

1

There are 1 best solutions below

3
On BEST ANSWER

Yes

https://github.com/elastic/elasticsearch-net/blob/develop/src/Nest/DSL/SearchDescriptor.cs line number 135

    public static void Update(IConnectionSettingsValues settings, ElasticsearchPathInfo<SearchRequestParameters> pathInfo, ISearchRequest request)
    {
        pathInfo.HttpMethod = request.RequestParameters.ContainsKey("source") ? PathInfoHttpMethod.GET : PathInfoHttpMethod.POST;
    }

Obviously you need to have SearchRequest.RequestParameters.ContainsKey("source") return true for it to do a Get.

In future. Just RTFM.