Changing SearchResults class to a list<type>


(Dennis) #1

Anyone have any ideas on the quickest way to turn the SearchHits[] array in
the SearchResult into a list of objects of type 'type'?

So if I make a Java class with two attributes:

class myClass
{
long id;
String name
}

Store many thousands of them, storing all the fields, do a search on them,
get the SearchResult, and want to turn the SearchHits array into a List of
myClass objects, is there some standard techniques for taking all the
fields and values of a 'SearchHit' and assigning them to the fields of an
object, 'en mass', or is it going to be one at a time?


(David Pilato) #2

I use Jackson for that.
I iterate the result array and give to Jackson the source then I add the javabean to my own collection.

HTH
David

Le 17 mai 2012 à 05:05, Dennis gearond@gmail.com a écrit :

Anyone have any ideas on the quickest way to turn the SearchHits[] array in the SearchResult into a list of objects of type 'type'?

So if I make a Java class with two attributes:

class myClass
{
long id;
String name
}

Store many thousands of them, storing all the fields, do a search on them, get the SearchResult, and want to turn the SearchHits array into a List of myClass objects, is there some standard techniques for taking all the fields and values of a 'SearchHit' and assigning them to the fields of an object, 'en mass', or is it going to be one at a time?


(system) #3