2
votes

I am using solr techproducts example.

I have created a field type

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

and then I have created a field

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

I have kept the externalFieldFile(external_entryRankFile.txt) in the following location /Users/yatingrover/softwares/solr-7.5.0/example/techproducts/solr/techproducts/data

Contents of the file external_entryRankFile.txt

TWINX2048-3200PRO=10

IW-02=1500

VA902B=170000

now I am running this query

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

also when I am running the query

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

I am getting all pageViews =0

sample response

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

The results are not getting sorted on the base of external field file, can anyone point out what I am missing?

1

1 Answers

1
votes

As per the documentation

The file itself is located in Solr's index directory, which by default is $SOLR_HOME/data. The name of the file should be external_fieldname or external_fieldname.*. For the example above, then, the file could be named external_entryRankFile or external_entryRankFile.txt.

They have mentioned that file name should be external_fieldname. If you change your file name to external_ pageViews.txt, that will solve your problem.