【问题标题】:Elasticsearch exact match only for specific fields on multi_match fieldsElasticsearch 仅针对 multi_match 字段上的特定字段精确匹配
【发布时间】:2017-03-02 09:44:09
【问题描述】:

我试图只搜索以下字段:

  1. 名称(产品名称)
  2. vendor.username
  3. 供应商名称
  4. 类别名称

但结果范围很广,我希望结果与用户输入的内容完全相同。

例子:

我输入 Cloth A 我希望结果是完全正确 Cloth A 而不是其他包含 ClothA

这是我的尝试:

```

GET /products/_search
{
  "query": {
    "filtered": {
      "query": {
        "multi_match": {
          "query": "cloth A", 
          "fields": [
            "name",
            "vendor.name",
            "vendor.username",
            "categories_name"
          ] 
        }
      },
      "filter": [
        {
          "term": {
          "is_available": true
          }
        },
        {
          "term": {
            "is_ready": true
          }
        },
        {
          "missing": {
            "field": "deleted_at"
          }
        }
      ]
    }
  }
}

```

我该怎么做?提前致谢

【问题讨论】:

    标签: ruby-on-rails elasticsearch search


    【解决方案1】:

    这个有效:

    "multi_match": {
      "type": "phrase"
     }
    

    【讨论】:

      【解决方案2】:

      把这个放在你的multi_match

      "multi_match": {
        "type": "best_fields"
       }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多