Search code examples
solrlucenesolrj

Retrieving multivalued field elements


I've multivalued field and i want to display all array elements using solrj command.

I used the command mentioned below but i'm able to retrieve only 1st element of the array.

response.getResults().get(0).getFieldValueMap().get("discussions") Output: Creation Time - 2014-06-12 17:37:53.0

NOTE: "discussions" is multivalued field in solr which contains

 <arr name="discussions">
  <str>Creation Time - 2014-06-12 17:37:53.0</str>
  <str>Last modified Time - 2014-06-12 17:42:09.0</str>
  <str>Comment - posting bug from risk flows ...posting comment from risk flows ...syncing comments ...</str>
</arr>

Is there any solrj API used for retrieving multivalued elements or its not possible..? Please help me..


Solution

  • SolrJ has dedicated methods to get a Collection of values for the field instead of a single value: getFieldValues(<fieldname>) or to get a map of all fields: getFieldValuesMap() (pay attention to the extra s).