【问题标题】:Solr external field file not sorting results?Solr外部字段文件不排序结果?
【发布时间】:2018-12-13 01:51:21
【问题描述】:

我正在使用 solr techproducts 示例。

我已经创建了一个字段类型

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field-type" : {
     "name":"entryRankFile",
     "keyField":"id",
     "defVal":"0",
     "stored":"false",
     "indexed":"false",
     "class":"solr.ExternalFileField"
     }
}' http://localhost:8983/api/cores/techproducts/schema

然后我创建了一个字段

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-field":{
     "name":"pageViews",
     "type":"entryRankFile",
     "indexed":"true",
     "stored":"true" }
}' http://localhost:8983/api/cores/techproducts/schema

我已将 externalFieldFile(external_entryRankFile.txt) 保存在以下位置 /Users/yatingrover/softwares/solr-7.5.0/example/techproducts/solr/techproducts/data

文件external_entryRankFile.txt的内容

TWINX2048-3200PRO=10

IW-02=1500

VA902B=170000

现在我正在运行这个查询

http://localhost:8983/solr/techproducts/select?q=*&sort={!func}pageViews%20desc

当我运行查询时

http://localhost:8983/solr/techproducts/select?q=*&sort={!func}pageViews%20desc&fl=id,%20score,%20field(pageViews)

我得到所有 pageViews =0

示例响应

response: {
numFound: 32,
start: 0,
maxScore: 1,
docs: [
{
id: "TWINX2048-3200PRO",
score: 1,
field(pageViews): 0
},
{
id: "VS1GB400C3",
score: 1,
field(pageViews): 0
},
{
id: "VDBDB1A16",
score: 1,
field(pageViews): 0
},
{
id: "MA147LL/A",
score: 1,
field(pageViews): 0
},

结果没有根据外部字段文件进行排序,谁能指出我遗漏了什么?

【问题讨论】:

    标签: solr


    【解决方案1】:

    根据文档

    文件本身位于 Solr 的 index 目录中,默认情况下 是 $SOLR_HOME/数据。文件名应为 external_fieldname 或 external_fieldname.*。那么对于上面的例子,文件可以 命名为 external_entryRankFile 或 external_entryRankFile.txt。

    他们提到文件名应该是external_fieldname。如果你把文件名改成external_pageViews.txt,就可以解决你的问题了。

    【讨论】:

    • 完美,我在文件名上犯了一个非常愚蠢的错误,非常感谢
    猜你喜欢
    • 2016-11-04
    • 2023-03-15
    • 2012-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2011-12-20
    • 2016-07-03
    相关资源
    最近更新 更多