# How to extract found terms into keyword fields

**URL:** <https://discuss.elastic.co/t/how-to-extract-found-terms-into-keyword-fields/174604>\
**Category:** Elasticsearch\
**Created:** [March 29, 2019, 8:02pm UTC](https://discuss.elastic.co/t/how-to-extract-found-terms-into-keyword-fields/174604 "2019-03-29T20:02:20Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [April 25, 2019, 4:18pm UTC](https://discuss.elastic.co/t/how-to-extract-found-terms-into-keyword-fields/174604/3 "2019-04-25T16:18:43Z")

</div>

This sounds like an entity extraction problem and fortunately twitter handles and hashtags are easily identified using a simple [regular expression](https://regex101.com/).  
I tend to use Python code to prepare docs but this is a personal choice and Logstash or ingest pipelines are other document-enrichment tools. [This question](https://discuss.elastic.co/t/how-to-extract-terms-into-a-new-field-while-indexing/174805) explores the same problem.  
Either way, you should be OK to have a plain doc with your original `text` field and use a `keyword` type structured field with an array of the extracted handles or tags. If you want to remember where these handles were extracted from the text it might be an idea to use an [annotated\_text](https://www.elastic.co/blog/search-for-things-not-strings-with-the-annotated-text-plugin) field instead.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-extract-found-terms-into-keyword-fields/174604)._
