# Elasticsearch query to find occurrences of some word in message

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384>\
**Category:** Elasticsearch\
**Created:** [May 6, 2016, 8:38am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384 "2016-05-06T08:38:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakashkumar](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@prakashkumar](https://discuss.elastic.co/u/prakashkumar)\
**Post date:** [May 6, 2016, 8:38am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/1 "2016-05-06T08:38:54Z")

</div>

"hits": [  
{  
"\_index": "filebeat-2016.05.06",  
"\_type": "log",  
"\_id": "AVSFCkQD9VvAndW3DfOv",  
"\_score": 1,  
"\_source": {  
"message": "javax.mail.internet.AddressException: Missing local name in string ``@gmail.com''",  
"@version": "1",  
"@timestamp": "2016-05-06T07:48:38.986Z",  
"beat": {  
"hostname": "akash",  
"name": "akash"  
},  
"count": 1,  
"fields": null,  
"input\_type": "log",  
"offset": 0,  
"source": "c:\Users\akashsoni\Downloads\k\Test\new 1.log",  
"type": "log",  
"host": "akash",  
"tags": [  
"beats\_input\_codec\_plain\_applied"  
],  
"message\_type": "Exception"  
}  
--------------------------------------------------------------------------------------------------------------------------------------------------Hi,  
My question is how to find out the occurrences of "Missing local name in string" ,which is present in message.Number of count that how many time this word is in my elasticsearch database.

---

<div class="post-metadata">

**Author:** ![prakashkumar](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@prakashkumar](https://discuss.elastic.co/u/prakashkumar)\
**Post date:** [May 6, 2016, 8:40am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/2 "2016-05-06T08:40:02Z")

</div>

Or presented in my particular index.

---

<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:** [May 7, 2016, 9:04am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/3 "2016-05-07T09:04:28Z")

</div>

You can run a simple query for this - [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-search.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-search.html) - or maybe a count query - [https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-count.html](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-count.html)

---

<div class="post-metadata">

**Author:** ![prakashkumar](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@prakashkumar](https://discuss.elastic.co/u/prakashkumar)\
**Post date:** [May 10, 2016, 6:53am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/4 "2016-05-10T06:53:58Z")

</div>

Not working sir ,

GET /filebeat-2016.05.10/\_count  
{  
"query" : {  
"term" : { "message": "javax.mail.internet.AddressException: Missing local name in string ``@gmail.com''" }  
}  
}

output:  
{  
"count": 0,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
}  
}

---

<div class="post-metadata">

**Author:** ![prakashkumar](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@prakashkumar](https://discuss.elastic.co/u/prakashkumar)\
**Post date:** [May 10, 2016, 6:55am UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/5 "2016-05-10T06:55:01Z")

</div>

{  
"took": 2,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 3,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "filebeat-2016.05.10",  
"\_type": "log",  
"\_id": "AVSZY2wJpqVzoumUKIdO",  
"\_score": 1,  
"\_source": {  
"message": "javax.mail.internet.AddressException: Missing local name in string ``@gmail.com''",  
"tags": [  
"\_jsonparsefailure",  
"beats\_input\_codec\_json\_applied"  
],  
"@version": "1",  
"@timestamp": "2016-05-10T06:38:25.899Z",  
"beat": {  
"hostname": "akash",  
"name": "akash"  
},  
"count": 1,  
"fields": null,  
"input\_type": "log",  
"offset": 0,  
"source": "c:\Users\akashsoni\Downloads\k\Test\new 1.log",  
"type": "log",  
"host": "akash",  
"message\_type": "Exception"  
}  
},

---

<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 5, 2017, 10:52pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-find-occurrences-of-some-word-in-message/49384/6 "2017-07-05T22:52:54Z")

</div>


