Hi - I am examining a SolrDocument I retrieved through a query. The field I am 
looking at is declared this way in my schema:

<field name="uri" type="string" indexed="true" stored="true" 
multivalued="false" required="true" />

I know multivalued defaults to false, but I set it explicitly because I'm 
seeing some unexpected behavior. I retrieve the value of the field like so:

final String resource = (String)document.getFieldValue("uri");


However, I get an exception because an ArrayList is returned. I confirmed that 
the returned ArrayList has one element with the correct value, but I thought 
getFieldValue would return a String if the field is single valued. When I index 
the document, I have some code that retrieves the same field in the same way 
from the SolrInputDocument, and that code works.

I looked at the code for SolrDocument.setField and it looks like the only way a 
field should be set to an ArrayList is if one is passed in by the code creating 
the SolrDocument. Why would it do that if the field is not multivalued?

Is this behavior expected?

-Rich

Reply via email to