【问题标题】:Why I can retrieve records in Elastic search using bool query?为什么我可以使用 bool 查询在弹性搜索中检索记录?
【发布时间】:2014-09-25 04:51:25
【问题描述】:

我在 ElasticSearch 中插入了一条记录,我可以在这里看到:

但是这个查询什么也没返回:

{
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": {
            "term": {
              "name": "Ehsanl"
            }
          }
        }
      }
    }
  }
}

我使用post 方法将此查询发布给该用户:http://127.0.0.1:9200/mydb/customers2/_search 这有什么问题?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    尝试将名称命名为“ehsanl”。全部小写。

    【讨论】:

      【解决方案2】:

      您在屏幕截图中看到的是索引时的原始文档(_source 字段)。

      但是,默认情况下会分析字符串字段(有关分析的更多详细信息,请参阅answer)。

      使用standard 分析器,您的名称值应该已小写为ehsanl 并以这种方式存储在索引中:term 查询搜索索引中不存在的确切值Ehsanl

      你可以:

      • ehsanl 值与term 查询结合使用
      • Ehsanl 值与match 查询结合使用,这将在搜索之前应用相同的分析器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-01-13
        • 1970-01-01
        • 2017-05-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多