Did you perhaps change the schema but not re-index? I'm grasping at straws here, but something like this might happen if part of your index has that field as a multi-valued field....
If that't not the problem, what version of solr are you using? I presume this is SolrJ? Best Erick On Wed, Jun 15, 2011 at 2:21 PM, Simon, Richard T <richard_si...@hms.harvard.edu> wrote: > 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 >