【问题标题】:Seach all types and all indexes in elasticsearch using NEST使用 NEST 在 elasticsearch 中搜索所有类型和所有索引
【发布时间】:2015-01-07 09:50:09
【问题描述】:

各位, 我使用 .net NEST 库来查询 ElasticSearch。搜索操作有问题。 我想搜索所有类型的所有索引中的所有文档。

如何在不确定文档类型的情况下搜索所有文档?以及如何将检索到的结果转换为 Json 或类似的对象?

【问题讨论】:

    标签: c# elasticsearch nest


    【解决方案1】:

    经过调查,我发现这段代码对我有帮助:

    client.Search<dynamic>(s => s
          .AllIndices()
          .AllTypes()
          .Query(q => q
                 .QueryString(qs => qs.Query(query)
          )));
    

    搜索所有索引和所有类型。 当然另一种方式是使用:

    client.Raw.Search()
    

    函数并以原始 json 格式传递查询的每个细节。

    为了转换成 json,最好的选择是使用JsonValue.Parse()

    【讨论】:

      猜你喜欢
      • 2015-09-12
      • 1970-01-01
      • 2016-11-26
      • 1970-01-01
      • 1970-01-01
      • 2019-03-09
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      相关资源
      最近更新 更多