# Creating an analyzer that works with # and @ in the following manner

**URL:** <https://discuss.elastic.co/t/creating-an-analyzer-that-works-with-and-in-the-following-manner/181731>\
**Category:** Elasticsearch\
**Created:** [May 20, 2019, 2:15am UTC](https://discuss.elastic.co/t/creating-an-analyzer-that-works-with-and-in-the-following-manner/181731 "2019-05-20T02:15:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Baumgartner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jason_baumgartner/32/92716_2.png) [@Jason\_Baumgartner](https://discuss.elastic.co/u/Jason_Baumgartner)\
**Post date:** [May 20, 2019, 2:15am UTC](https://discuss.elastic.co/t/creating-an-analyzer-that-works-with-and-in-the-following-manner/181731/1 "2019-05-20T02:15:49Z")

</div>

If I index a tweet body with the following text:

"Hey @joesmith are you watching #gameofthrones?"

I would like the tokenizer to create the following tokens from @joesmith and #gameofthrones

@joesmith  
joesmith  
#gameofthrones  
gameofthrones

If someone searches for gameofthrones, it will match the above tweet text. If they search for #gameofthrones it would also match. The same behavior would also exist for searching for joesmith or @joesmith.

Is this possible? Which tokenizer / analyzer should I be looking at using?

---

<div class="post-metadata">

**Author:** ![gabriel\_tessier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_tessier/32/27911_2.png) [@gabriel\_tessier](https://discuss.elastic.co/u/gabriel_tessier)\
**Post date:** [May 20, 2019, 4:08am UTC](https://discuss.elastic.co/t/creating-an-analyzer-that-works-with-and-in-the-following-manner/181731/2 "2019-05-20T04:08:23Z")

</div>

Hi,

the simplest way to do this is using a Whitespace analyzer for the @joesmith and another analyzer with a tokeniser defined with "discard\_punctuation" : "true" to have the joesmith.

There's more resources here:

> <https://stackoverflow.com/questions/2555074/tokenizing-twitter-posts-in-lucene>

---

<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:** [June 17, 2019, 4:08am UTC](https://discuss.elastic.co/t/creating-an-analyzer-that-works-with-and-in-the-following-manner/181731/3 "2019-06-17T04:08:25Z")

</div>

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