2

I configured my external file field configuration like follows:

    < field name="idRank" type="idRankFile" indexed="true" stored="true" omitNorms="true" omitTermFreqAndPositions="true" valType="pfloat" />

    < fieldType name="idRankFile" keyField="id" defVal="10" stored="true" indexed="true" class="solr.ExternalFileField" valType="pfloat|float|tfloat" />

Following are the value I kept in the file named :external_idRank.txt.Here keys are the values of size field in the document.

2938025 = 100.0 

4030380 = 115.0

9751 = 125.0

12738 = 135.0 

9752 = 145.0

I used the following query to retrieve the result, sorting it based on the idRank value:

/solr/collection1/select/?&q=content:* _ val _:"sum(idRank,1)"&fl=size&rows=100

But, when I used the following query it throws Exception like follows,

java.lang.NullPointerException at org.apache.solr.search.function.FileFloatSource.getFloats(FileFloatSource.java:273) at org.apache.solr.search.function.FileFloatSource.access$000(FileFloatSource.java:51) at org.apache.solr.search.function.FileFloatSource$2.createValue(FileFloatSource.java:147) at org.apache.solr.search.function.FileFloatSource$Cache.get(FileFloatSource.java:190) at org.apache.solr.search.function.FileFloatSource.getCachedFloats(FileFloatSource.java:141) at org.apache.solr.search.function.FileFloatSource.getValues(FileFloatSource.java:84) at org.apache.lucene.queries.function.valuesource.MultiFloatFunction.getValues(MultiFloatFunction.java:65) at org.apache.lucene.queries.function.FunctionQuery$AllScorer.(FunctionQuery.java:120) at org.apache.lucene.queries.function.FunctionQuery$FunctionWeight.scorer(FunctionQuery.java:95) at org.apache.lucene.search.BooleanQuery$BooleanWeight.scorer(BooleanQuery.java:323) at

What should I make to execute this query without exception?

Bharadwaj
  • 2,535
  • 1
  • 22
  • 35
gangatharan
  • 781
  • 1
  • 12
  • 28

1 Answers1

1

Instead of your file content being:

2938025 = 100.0

4030380 = 115.0

9751 = 125.0

12738 = 135.0

9752 = 145.0

try keeping your file exactly as specified in https://lucene.apache.org/solr/api-4_0_0-BETA/org/apache/solr/schema/ExternalFileField.html i.e. like:

2938025=100.0
4030380=115.0
9751=125.0
12738=135.0
9752=145.0

Also try changing your fieldType definition to:

<fieldType name="idRankFile" keyField="id" defVal="10" class="solr.ExternalFileField" valType="float" />

Note that indexed and stored don't make sense for external file fields.

arun
  • 10,685
  • 6
  • 59
  • 81