# Get count of analyzed strings as a result back within list of fields

**URL:** <https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578>\
**Category:** Elasticsearch\
**Created:** [November 18, 2016, 6:50pm UTC](https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578 "2016-11-18T18:50:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casieowen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casieowen/32/8734_2.png) [@casieowen](https://discuss.elastic.co/u/casieowen)\
**Post date:** [November 18, 2016, 6:50pm UTC](https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578/1 "2016-11-18T18:50:51Z")

</div>

Hi! I could use help with this query.

GET index\_\*/\_search?size=20  
{  
"size": 0,  
"\_source": ["sentimentScore","category", "contentAnalyzed"],  
"query": {  
"bool": {  
"must": [  
{ "match\_phrase\_prefix": {"contentAnalyzed": "x" }},  
{ "match": {"language": "en" }}  
]  
}  
}  
}

Returning results like this:

{  
"\_index": "x",  
"\_type": "x",  
"\_id": "x",  
"\_score": 6.3490815,  
"\_source": {  
"sentimentScore": 0.6034262,  
"contentAnalyzed": "string of text",  
"category": "category"  
}  
}

How do I get a count of documents with the exact string in the contentAnalyzed field (which is analyzed) back in the result set?

Thanks,  
Casie

---

<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:** [November 21, 2016, 8:36am UTC](https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578/2 "2016-11-21T08:36:09Z")

</div>

Hi,

for exact phrase matches you need to use the `match_phrase` query. If you run this on an analyzed field (which I guess `contentAnalyzed` is, judging from its name) you might still get matches that are not "exact" string matches (depending on what you mean by "exact"), e.g. mit different lowecasing etc...

If you need really "exact" (as in same case, full field, no stemming etc...) matches, you need another field that is not analyzed. Elasticsearch 5.0 has the [keyword datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/keyword.html) for that.

The total document count matching a query should be part of the response, what are you missing there?

---

<div class="post-metadata">

**Author:** ![casieowen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/casieowen/32/8734_2.png) [@casieowen](https://discuss.elastic.co/u/casieowen)\
**Post date:** [November 21, 2016, 10:39pm UTC](https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578/3 "2016-11-21T22:39:20Z")

</div>

> [@casieowen](#):
>
> GET index\_\*/\_search?size=20  
> {  
> "size": 0,  
> "\_source": ["sentimentScore","category", "contentAnalyzed"],  
> "query": {  
> "bool": {  
> "must": [  
> { "match\_phrase\_prefix": {"contentAnalyzed": "x" }},  
> { "match": {"language": "en" }}  
> ]  
> }  
> }  
> }

Thanks!

---

<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:** [December 19, 2016, 10:40pm UTC](https://discuss.elastic.co/t/get-count-of-analyzed-strings-as-a-result-back-within-list-of-fields/66578/4 "2016-12-19T22:40:03Z")

</div>

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