# (Spark) Top K results in esRDD (beginner question)

**URL:** <https://discuss.elastic.co/t/spark-top-k-results-in-esrdd-beginner-question/23678>\
**Category:** Elasticsearch\
**Created:** [May 24, 2015, 11:07am UTC](https://discuss.elastic.co/t/spark-top-k-results-in-esrdd-beginner-question/23678 "2015-05-24T11:07:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tal](https://avatars.discourse-cdn.com/v4/letter/t/54ee81/32.png) [@tal](https://discuss.elastic.co/u/tal)\
**Post date:** [May 24, 2015, 11:07am UTC](https://discuss.elastic.co/t/spark-top-k-results-in-esrdd-beginner-question/23678/1 "2015-05-24T11:07:51Z")

</div>

Hey,  
I just started using ES and spark, and i'm trying to get only the k best  
results by score, for a really simple query on simple documents (just id  
and content text)  
How can i populate the RDD with only the top K results for that query? (i  
tried using the size option but since it's just page size and it seems that  
the rdd creation runs over all pages i still get all the results)

it would be great if anyone can point me in the right direction,  
is it top\_hits ? (even though i don't need any bucketing or anything like  
that?)

thanks!

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d0a65329-cb76-4a09-b9bd-4864ca9bc8ec%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d0a65329-cb76-4a09-b9bd-4864ca9bc8ec%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:12am UTC](https://discuss.elastic.co/t/spark-top-k-results-in-esrdd-beginner-question/23678/2 "2017-07-06T00:12:11Z")

</div>


