【问题标题】:Solr syntax for phrase query短语查询的 Solr 语法
【发布时间】:2018-07-05 09:13:12
【问题描述】:

我有一个有定义的字段:

"replace-field": {
    "name":"search_words",
    "type":"lowercase",
    "stored":true,
    "indexed": true,
    "multiValued": true
}

包含句子作为数组(因此 multiValued: true):

"id":500
"search_words":["How much oil should you pour into the engine",
          "How important is engine oil?]

当用户输入短语“engine oil”时,我应该如何创建一个将返回该文档(id = 500)的查询? 通过单个术语查询,我可以使用 *engine* 并且它会发现该文档,因为 engine 位于句子的中间,但我找不到能够在句子中搜索短语的方法。甚至可以使用 solr 吗?

【问题讨论】:

    标签: solr lucene


    【解决方案1】:

    Solr 支持短语搜索,并且是它的实际设计目的。默认情况下,通配符搜索并不是您应该使用 Solr 的真正方式 - 字段类型应该告诉 Solr 如何处理字段中的文本,以便在以常规方式查询时获得命中。

    在这种情况下,标准 text_en 可能会正常工作,或者使用标准标记器和小写过滤器(可能还有一个 WordDelimiterGraphFilter 来去除特殊字符)的字段定义。

    查询将是search_words:"engine oil"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 1970-01-01
      • 2015-11-11
      • 1970-01-01
      • 1970-01-01
      • 2013-06-27
      • 1970-01-01
      相关资源
      最近更新 更多