The Javadoc for IndexableField.stringValue says "Non-null if this field has a string value". In your case, a null value should have been returned since the field has a numeric value rather than a string value. Was this not the case?

You should call the numericValue method for the numeric field.

-- Jack Krupansky

-----Original Message----- From: ravicv
Sent: Wednesday, September 26, 2012 8:19 AM
To: solr-user@lucene.apache.org
Subject: How to retrive value from float field in custom request handler?

HI All,

I have wrote a custom request handler which will retrieve some fields and
apply some business logic before sending response back.

My schema is:

<field name="field1" type="string" indexed="false" stored="true" />
<field name="field2" type="float" indexed="true" stored="true"  />

I am storing both fields, but i was unable to retrieve value of field2.
I am able to retrieve value of field1. I tried to create a new string
field(field3) and i am able to retrieve value.

Is their any special way to retrieve values for float fields?
Can someone throw some light on this...

My custom handler code snippet:

TopDocs top = searcher.search(QParser.getParser(query, null,
localReq).getQuery(),10);
SolrIndexReader reader = searcher.getReader();
if (top.totalHits > 0) {
try {
for (ScoreDoc hit : top.scoreDocs) {
Document doc = reader.document(hit.doc);
System.out.println(doc.getField("field1").stringValue()); // Able to
retrive value
System.out.println(doc.getField("field2").stringValue()); // Not able to
retrive value
}
}catch(Exception e){}

Thanks,
Ravi





--
View this message in context: http://lucene.472066.n3.nabble.com/How-to-retrive-value-from-float-field-in-custom-request-handler-tp4010478.html Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to