# Querying smileys in tweets using Elasticsearch

**URL:** <https://discuss.elastic.co/t/querying-smileys-in-tweets-using-elasticsearch/24582>\
**Category:** Elasticsearch\
**Created:** [June 29, 2015, 10:31pm UTC](https://discuss.elastic.co/t/querying-smileys-in-tweets-using-elasticsearch/24582 "2015-06-29T22:31:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reza\_sadoddin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/reza_sadoddin/32/3437_2.png) [@reza\_sadoddin](https://discuss.elastic.co/u/reza_sadoddin)\
**Post date:** [June 29, 2015, 10:31pm UTC](https://discuss.elastic.co/t/querying-smileys-in-tweets-using-elasticsearch/24582/1 "2015-06-29T22:31:03Z")

</div>

Hello,  
I have trouble specifying a query which search for some smileys in tweets. Can anyone show me an example of a working query? I have tried several ideas for escaping a simple smiley like ":)", but none of them can capture a smiley.

Just to mention that I am indexing tweet data using Twitter river plugin.  
Thank you,

~R

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 1, 2015, 11:05am UTC](https://discuss.elastic.co/t/querying-smileys-in-tweets-using-elasticsearch/24582/2 "2015-07-01T11:05:14Z")

</div>

You probably indexed your tweets without specifying an analyzer. In this case the default Standard Analyzer is used, which in turn uses the Standard Tokenizer. This tokenizer will filter out characters you usually find in smileys (like ":;))" etc...), so you can't serach for them later.

Try adding a mapping which preserves punctuation, e.g. the Whitespace Analyzer. Here is a short example in Sense notation:

```auto
DELETE /_all

PUT /test

PUT /test/_mapping/my_type
{
    "my_type": {
        "properties": {
            "text": {
                "type": "string",
                "analyzer": "whitespace"
            }
        }
    }
}

POST /test/my_type
{
    "text": "Don't worry, be :) now!"
}

GET /test/my_type/_search
{
  "query": {
    "match": {
      "text": ":)"
    }
  }
}

```

Which should give you

```auto
"hits": [
         {
            "_index": "test",
            "_type": "my_type",
            "_id": "AU5JRT98rcrDj8N_41cb",
            "_score": 0.13424811,
            "_source": {
               "text": "Don't worry, be :) now!"
            }
         }
      ]

```

You can find more information about controlling anaysis here: [https://www.elastic.co/guide/en/elasticsearch/guide/current/\_controlling\_analysis.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/_controlling_analysis.html)

---

<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:04am UTC](https://discuss.elastic.co/t/querying-smileys-in-tweets-using-elasticsearch/24582/3 "2017-07-06T00:04:20Z")

</div>


