有没有办法告诉 NEST 在执行搜索时使用 GET 而不是 POST?与 ElasticSearch 文档显示使用 GET 的 CURL 类似,我想在使用 NEST 时使用 GET,而不是像目前那样使用 POST。
最佳答案
是的
https://github.com/elastic/elasticsearch-net/blob/develop/src/Nest/DSL/SearchDescriptor.cs第 135 行
public static void Update(IConnectionSettingsValues settings, ElasticsearchPathInfo<SearchRequestParameters> pathInfo, ISearchRequest request)
{
pathInfo.HttpMethod = request.RequestParameters.ContainsKey("source") ? PathInfoHttpMethod.GET : PathInfoHttpMethod.POST;
}
显然你需要 SearchRequest.RequestParameters.ContainsKey("source")
返回 true
让它做一个Get
.
future 。只是 RTFM。
关于c# - NEST - 使用 GET 而不是 POST/PUT 进行搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30984515/