【问题标题】:Fuzziness across multiple fields -- only use fuzziness on certain fields跨多个领域的模糊性——仅在某些领域使用模糊性
【发布时间】:2017-12-14 19:32:13
【问题描述】:

有没有办法只在某些列上使用模糊性进行cross_field 搜索?例如:

match against:
- name (fuzziness=1)
- country (fuzziness=0)

所以搜索“John USA”会匹配,搜索“Jon USA”会匹配,但搜索“John AUS”不会匹配。这将如何实现?

【问题讨论】:

  • 没有人回答关于 StackOverflow 的 ES 问题吗?是气馁还是他们的论坛上的东西(我也没有发现他们的论坛有帮助)。
  • 有时人们需要更长的时间才能回答,你需要耐心;-)
  • official documentation中所述:The fuzziness parameter cannot be used with the cross_fields type.

标签: python elasticsearch lucene elasticsearch-plugin


【解决方案1】:

正如文档中所写,Val 在上面的评论中说,“模糊参数不能与 cross_fields 类型一起使用”。

基于我阅读的herehere。对于您描述的问题,我将使用 AUTO 值作为 fuzziness 属性。同样,我会更进一步,并指定“名称”列应该比国家/地区更相关,因为您更有可能匹配名称而不是国家/地区(由于您为您提供的结构输入)。

{
   "size": 100,
   "query": {
      "multi_match": {
         "query": "John Doe USA",
         "fields": [
            "name^3",
            "country"
         ],
         "fuzziness": "AUTO",
         "max_expansions": 50,
         "prefix_length": 0
      }
   }
}

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    • 2010-12-20
    • 1970-01-01
    • 2021-03-20
    • 2012-12-11
    • 2011-04-03
    • 1970-01-01
    相关资源
    最近更新 更多