【问题标题】:Apache Solr undefined field score field in function query函数查询中的 Apache Solr 未定义字段得分字段
【发布时间】:2016-01-19 07:19:21
【问题描述】:

我正在使用 solr 4.10。我必须根据字段提升和文档分数更改文档的相关性。为此,我知道我应该使用函数查询。以下是 schema 中 boost 字段的语法

<field name="boost" type="float" stored="true" indexed="false" default="1.0"/>

我的第一个问题是函数查询只能用于存储字段吗?

当我尝试使用上述架构时,如以下查询

http://localhost:8983/solr/select?q=bank&df=keywords&fl=id&sort=pow(score,%20boost)%20asc

有一些错误说像

sort param could not be parsed as a query, and is not a field that exists in the index: 

然后我改变了架构像

<field name="boost" type="float" stored="true" indexed="true" default="1.0"/>

然后上面的问题消失了,但是查询出现了一个新的错误

http://localhost:8983/solr/select?q=bank&df=keywords&fl=id,pow(score,%20boost)

出现以下错误

<lst name="error">
<str name="msg">undefined field: "score"</str>
<int name="code">400</int>
</lst>

我哪里错了? 我是否正确更改了 boost 字段的属性?

【问题讨论】:

  • 在对 schema.xml 文件进行更改后,您是否运行了索引器(完整索引)?
  • 是的,我删除了所有文档并再次索引它们

标签: apache solr lucene solr-boost


【解决方案1】:

我建议使用 boost 函数并仅按分数排序(默认 = 不需要 order 参数)。

bf=linear(boost,100,0)

您可以使用其他功能。这取决于您的用例。 只需查看solr docs for function queries

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    • 2022-01-17
    • 2016-04-08
    相关资源
    最近更新 更多