Solr外部字段文件未排序结果?

时间:2018-12-13 01:51:22

标签: solr

我正在使用solr技术产品示例。

我创建了一个字段类型

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
},

结果未根据外部字段文件进行排序,任何人都可以指出我所缺少的内容吗?

1 个答案:

答案 0 :(得分:1)

根据文档

  

文件本身位于Solr的索引目录中,默认情况下位于   是$ SOLR_HOME / data。文件名应为external_fieldname   或external_fieldname。*。对于上面的示例,该文件可以   命名为external_entryRankFile或external_entryRankFile.txt。

他们提到文件名应为 external_fieldname 。如果将文件名更改为external_ pageViews.txt,则可以解决您的问题。

相关问题