【问题标题】:Elasticsearch pruned suggestionsElasticsearch 修剪建议
【发布时间】:2015-06-30 08:56:04
【问题描述】:

有人知道如何从建议结果集中过滤拼写错误吗?

此查询找到了很好的建议,但也包括部分拼写错误。例如“商业抵押”返回“商业抵押”,这很好,但“商业抵押”也返回“商业抵押”,因为商业条款仍然是错误的。

{
  "suggest" : {
    "text" : "comercial morgage",
    "simple_phrase" : {
      "phrase" : {
        "analyzer" : "standard",
        "field" : "title.raw",
        "max_errors" : 0.8,
        "size" : 3,
        "highlight": {
          "pre_tag": "<em>",
          "post_tag": "</em>"
        },
        "collate": {
           "query": { 
             "match": {
                 "title.raw" : "{{suggestion}}" 
             }
           },
           "prune": true 
         }
      }
    }
  }
}

返回

{
  "took": 42,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": { ... },
  "suggest": {
    "simple_phrase": [
      {
        "text": "comercial morgage",
        "offset": 0,
        "length": 17,
        "options": [
          {
            "text": "commercial mortgage",
            "highlighted": "<em>commercial mortgage</em>",
            "score": 0.0025874644,
            "collate_match": true
          },
          {
            "text": "commercial mortgages",
            "highlighted": "<em>commercial mortgages</em>",
            "score": 0.0022214006,
            "collate_match": true
          },
          {
            "text": "comercial mortgage",
            "highlighted": "comercial <em>mortgage</em>",
            "score": 0.0019709675,
            "collate_match": true
          }
        ]
      }
    ]
  }
}

“comercial [em]mortgage[/em]”的 collat​​e_match 是真的,即使这个确切的短语没有出现在任何文档标题中。

分数非常低且非常相似,因此我无法按分数进行过滤。

目前它在最后一页上看起来还不错,因为我使用了一些 javascript 来仅显示被 [em/] 标签包围的结果,但这是一个 hack,不是很好。

elasticsearch 的版本是 1.5.3,但我们可能会很快升级,所以我不能在建议中使用过滤器。

有谁知道如何过滤/修剪 title.raw 字段中不存在的任何建议?

谢谢。

【问题讨论】:

    标签: elasticsearch search-suggestion match-phrase


    【解决方案1】:

    在整理查询中,您可以使用任何您想要的查询。

    尝试为您的查询添加一个默认运算符,这样您就希望该字段中的所有术语都匹配。

    喜欢

    { "suggest" : { "text" : "comercial morgage", "simple_phrase" : { "phrase" : { "analyzer" : "standard", "field" : "title.raw", "max_errors" : 0.8, "size" : 3, "highlight": { "pre_tag": "<em>", "post_tag": "</em>" }, "collate": { "query": { "match": { "title.raw" : { "query": "{{suggestion}}", "operator" : "and" } } }, "prune": true } } } } }

    【讨论】:

      猜你喜欢
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-24
      相关资源
      最近更新 更多