# Get results of specific fields - SearchHitField Iterator?

**URL:** <https://discuss.elastic.co/t/get-results-of-specific-fields-searchhitfield-iterator/12580>\
**Category:** Elasticsearch\
**Created:** [June 28, 2013, 12:09pm UTC](https://discuss.elastic.co/t/get-results-of-specific-fields-searchhitfield-iterator/12580 "2013-06-28T12:09:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ES\_User](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@ES\_User](https://discuss.elastic.co/u/ES_User)\
**Post date:** [June 28, 2013, 12:09pm UTC](https://discuss.elastic.co/t/get-results-of-specific-fields-searchhitfield-iterator/12580/1 "2013-06-28T12:09:25Z")

</div>

Hi!

I use Version 0.90.1 of Elasticsearch and want to get the results of the  
indexfields.

Is it possible to iterate over SearchHitFields?  
I found this solution:  
\*  
final Iterator iterator = hit.iterator() ;  
while( iterator.hasNext() ) {  
final SearchHitField hitField = iterator.next() ;  
System.out.println(" field:"+hitField.getName()+"  
value count:"+hitField.getValues()size() ) \*

But when i try to use it, i get an error that i have to change the iterator  
to iterator

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:29am UTC](https://discuss.elastic.co/t/get-results-of-specific-fields-searchhitfield-iterator/12580/2 "2017-07-06T02:29:01Z")

</div>


