# Is there away to get a random word/words from a document?

**URL:** <https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470>\
**Category:** Elasticsearch\
**Created:** [June 17, 2022, 5:22am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470 "2022-06-17T05:22:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tasdiq\_Shaikh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tasdiq_shaikh/32/76982_2.png) [@Tasdiq\_Shaikh](https://discuss.elastic.co/u/Tasdiq_Shaikh)\
**Post date:** [June 17, 2022, 5:22am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470/1 "2022-06-17T05:22:33Z")

</div>

I want to display some random words on the screen which are present in the document. I'm using Elasticsearch 7.12.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 21, 2022, 1:44am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470/2 "2022-06-21T01:44:42Z")

</div>

I don't think there's a way to natively do this, the closest thing is [Random sampler aggregation | Elasticsearch Guide [8.2] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.2/search-aggregations-random-sampler-aggregation.html), but it's at a whole-document level.

---

<div class="post-metadata">

**Author:** ![Tasdiq\_Shaikh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tasdiq_shaikh/32/76982_2.png) [@Tasdiq\_Shaikh](https://discuss.elastic.co/u/Tasdiq_Shaikh)\
**Post date:** [June 23, 2022, 6:17am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470/3 "2022-06-23T06:17:04Z")

</div>

Thank you for responding to my question, Mark. Can we get all the keywords from a document which is indexed? Later on we can use those keywords to perform a search query.

---

<div class="post-metadata">

**Author:** ![Tasdiq\_Shaikh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tasdiq_shaikh/32/76982_2.png) [@Tasdiq\_Shaikh](https://discuss.elastic.co/u/Tasdiq_Shaikh)\
**Post date:** [June 24, 2022, 8:37am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470/4 "2022-06-24T08:37:27Z")

</div>

Not keywords, text(according to Elasticsearch). Can we get list of unique text terms available in a document?

---

<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 22, 2022, 8:37am UTC](https://discuss.elastic.co/t/is-there-away-to-get-a-random-word-words-from-a-document/307470/5 "2022-07-22T08:37:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
