【问题标题】:Elastic Search: JSON to NEST query without duplicates弹性搜索:没有重复的 JSON 到 NEST 查询
【发布时间】:2017-02-24 05:58:34
【问题描述】:

如何将json查询转换为下面的嵌套查询并去除重复?

{
      "size": 30,
      "query": {
          "multi_match": {
            "query": "london",
            "operator": "OR",
            "fields": [
            "name",
             "venueTown"
            ]
          }
  }
}

【问题讨论】:

    标签: c# elasticsearch nest


    【解决方案1】:

    您可以稍微简化一下聚合部分,并将热门匹配项放入

    var searchResult = client.Search<SearchResult>(request => request
        // Your existing query below...
        //.Query(q => q)
        .Size(0)
        .Aggregations(a => a
            // simplify the terms aggregation
            .Terms("query", tr => tr
                .Field("name")
                .Size(30)
            )
            // Add the top hits aggregation
            .TopHits("top", th => th
                .Size(1)
            )
        )
    );
    

    【讨论】:

    • 谢谢,但我没有得到想要的响应,如何将原始查询输入到 Nest 中,然后将其发送到 Elastic Search?
    • @ProgLearner 是的,请参阅stackoverflow.com/a/40076192/1831 了解选项
    猜你喜欢
    • 1970-01-01
    • 2015-07-17
    • 2021-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多