Reputation: 5418
I am using Solrj 6.2.0
to access a local Solr
core.
Everything works fine. I can search and find all the data I require.
I have one issue in that the QueryResponse
getResults()
method returns a SolrDocumentList
, which is a collection of SolrDocument
.
Each of the SolrDocument
hold a single data item as an array, when I retrieve each data item I receive an ArrayList
.
I have to loop through the ArrayList
s single entry and return a String.
What am I doing wrong?
Is there any way to get SolrJ
to return SolrDocument
that holds a data item as a Non Array?
Upvotes: 1
Views: 584
Reputation: 2924
If you are sure the field is a single value (or you need just the first value of the collection), you can use the getFirstValue(String name) method of the SolrDocument
.
Upvotes: 3