# Search for hashtags - Find exact matches only

**URL:** <https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103>\
**Category:** Elasticsearch\
**Created:** [January 3, 2014, 9:11pm UTC](https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103 "2014-01-03T21:11:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [January 3, 2014, 9:11pm UTC](https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103/1 "2014-01-03T21:11:51Z")

</div>

Hi,

I am using analyzer and filters described at  
[http://www.fullscale.co/blog/2013/03/04/preserving\_specific\_characters\_during\_tokenizing\_in\_elasticsearch.html](http://www.fullscale.co/blog/2013/03/04/preserving_specific_characters_during_tokenizing_in_elasticsearch.html)  
to preserve # chars. See mapping blow:

curl -XPUT '[http://localhost:9200/twitter](http://localhost:9200/twitter)' -d '{  
"settings" : {  
"index" : {  
"number\_of\_shards" : 1,  
"number\_of\_replicas" : 1  
},  
"analysis" : {  
"filter" : {  
"tweet\_filter" : {  
"type" : "word\_delimiter",  
"type\_table": ["# =\> ALPHA", "@ =\> ALPHA"]  
}  
},  
"analyzer" : {  
"tweet\_analyzer" : {  
"type" : "custom",  
"tokenizer" : "whitespace",  
"filter" : ["lowercase", "tweet\_filter"]  
}  
}  
}  
},  
"mappings" : {  
"tweet" : {  
"properties" : {  
"msg" : {  
"type" : "string",  
"analyzer" : "tweet\_analyzer"  
}  
}  
}  
}  
}'

But now when searching, e.g.  
[http://localhost:9200/\_search?pretty=true&q="%23elasticsearch"](http://localhost:9200/_search?pretty=true&q=%22%23elasticsearch%22) I get hits  
on ...#elasticsearch... but ALSO on elasticsearch without the #. How can i  
only search for full hashtags using the query\_string syntax? 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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/849ae584-c416-4f85-bba9-698367a1ccb1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/849ae584-c416-4f85-bba9-698367a1ccb1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![joa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joa/32/1807_2.png) [@joa](https://discuss.elastic.co/u/joa)\
**Post date:** [January 4, 2014, 4:09pm UTC](https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103/2 "2014-01-04T16:09:55Z")

</div>

Can someone help?

--  
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/aec204e6-ccf7-4f1b-bd22-0bd6e65e1547%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aec204e6-ccf7-4f1b-bd22-0bd6e65e1547%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 4, 2014, 5:36pm UTC](https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103/3 "2014-01-04T17:36:50Z")

</div>

You have enabled the tweet\_analyzer only for field "msg" so you should  
execute a field search, something like

curl '0:9200/\_search?pretty&q=msg:%23elasticsearch'

Or you change the \_all field analyzer also to tweet\_analyzer (which is  
probably not what you want), see  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-all-field.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-all-field.html)

Jörg

--  
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/CAKdsXoH-wJ2-FnjL4YtbE2AEr-9BWa2vYAadJey7gQvdVayQmA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoH-wJ2-FnjL4YtbE2AEr-9BWa2vYAadJey7gQvdVayQmA%40mail.gmail.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, 1:58am UTC](https://discuss.elastic.co/t/search-for-hashtags-find-exact-matches-only/15103/4 "2017-07-06T01:58:19Z")

</div>


