{!boost ...} 乘数与 dismax 查询解析器

{!boost ...} multiplier with dismax query parser

如何将 q={!boost ...} 乘法器与 dismax 查询解析器一起使用?

使用标准查询,您可以:

?q={!boost b=$multiplier}text:foo
&multiplier=...

但是,当我尝试对 dismax 执行等效操作时:

?defType=dismax
&q={!boost b=$multiplier}foo
&qf=text
&multiplier=...

我收到以下错误:

{
  "error": {
    "msg": "no field name specified in query and no default specified via 'df' param",
    "code": 400
  }
}

我猜测在 q 中指定 {!boost ...} 会覆盖 defType=dismax 并导致 q 的剩余部分使用标准查询解析器进行解析。如何将 {!boost ...} 与 dismax 一起使用?

注意:我是 运行 Solr 4.10.4.

根据Solr Relevancy FAQ § How can I boost the score of newer documents

To boost another query parser such as a dismax query, the value of the boost query is a full sub-query and hence can use the {!queryParser} syntax. Alternately, the defType param can be used in the boost local params to set the default type to dismax. The other dismax parameters may be set as top level parameters.

这意味着为了将 dismax(或任何其他查询解析器)与 boost 查询解析器一起使用,您需要构造参数为:

?q={!boost b=$multiplier v=$qq}
&qq={!dismax}foo
&qf=text
&multiplier=...

或者:

?q={!boost b=$multiplier defType=dismax}foo
&qf=text
&multiplier=...