# Changing SearchResults class to a list\<type\>

**URL:** <https://discuss.elastic.co/t/changing-searchresults-class-to-a-list-type/7736>\
**Category:** Elasticsearch\
**Created:** [May 17, 2012, 3:05am UTC](https://discuss.elastic.co/t/changing-searchresults-class-to-a-list-type/7736 "2012-05-17T03:05:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Dennis](https://discuss.elastic.co/u/Dennis)\
**Post date:** [May 17, 2012, 3:05am UTC](https://discuss.elastic.co/t/changing-searchresults-class-to-a-list-type/7736/1 "2012-05-17T03:05:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 17, 2012, 5:45am UTC](https://discuss.elastic.co/t/changing-searchresults-class-to-a-list-type/7736/2 "2012-05-17T05:45:40Z")

</div>

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](mailto: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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:28am UTC](https://discuss.elastic.co/t/changing-searchresults-class-to-a-list-type/7736/3 "2017-07-06T03:28:25Z")

</div>

Closed on July 6, 2017, 3:28am UTC


