【问题标题】:ElasticSearch (with NEST) search in multiple fieldsElasticSearch (with NEST) 在多个字段中搜索
【发布时间】:2013-08-13 11:29:23
【问题描述】:

我只想在类的两个属性(Id 和 RoundTemplateName)中搜索“searchText”。

.Query(q =>
   q.Term(f => f.Id, searchText)
   || q.Term(f => f.RoundTemplateName, searchText)

查询有什么问题?它只在 Id 属性中搜索...

提前谢谢你, 伊戈尔

【问题讨论】:

    标签: search elasticsearch nest


    【解决方案1】:

    该查询看起来不错,您可以通过打印result.ConnectionStatus.ToString() 来检查它生成的查询。

    您也可以使用Terms() 查询

    http://www.elasticsearch.org/guide/reference/query-dsl/terms-query/

    【讨论】:

      【解决方案2】:

      执行此操作的方法是使用 multi_match 查询 在下面的示例中,查询将针对两个字段(主题和消息)运行

      {
          "multi_match" : {
          "query":    "this is a test", 
          "fields": [ "subject", "message" ] 
        }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-12
        • 1970-01-01
        • 2015-09-12
        • 1970-01-01
        • 2018-12-22
        • 1970-01-01
        • 2020-09-03
        • 1970-01-01
        相关资源
        最近更新 更多