c# - NEST - 使用 GET 而不是 POST/PUT 进行搜索

标签 c# elasticsearch nest

有没有办法告诉 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/

相关文章:

c# - 如何为自定义队列实现 <IEnumerable>?

javascript - 在浏览器中调用 javascript 函数时指定的强制转换无效

elasticsearch - 如何将唯一的列数据插入elasticsearch?

不同键上的 Elasticsearch 聚合

elasticsearch - Logstash 仅将 mysql 中的一行选择查询索引到 Elasticsearch

c# - Nest Client在Elasticsearch中进行相等查询

c# - LINQ 从每个查询中获取第一行

elasticsearch - ElasticSearch-从热门单词中过滤停用词

c# - 索引未分析的映射无法使用嵌套

c# - 如何从 C# 中的简单数组中获取元素?