# Elasticsearch Full Text or Exact Value search

**URL:** <https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093>\
**Category:** Elasticsearch\
**Created:** [October 3, 2016, 4:48pm UTC](https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093 "2016-10-03T16:48:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreeram](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@sreeram](https://discuss.elastic.co/u/sreeram)\
**Post date:** [October 3, 2016, 4:48pm UTC](https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093/1 "2016-10-03T16:48:06Z")

</div>

Hi,

Below is my use case,

put /twitter/Company/1  
{  
"manufacturer": "ABC Technologies"  
}

put /twitter/Company/2  
{  
"manufacturer": "DEF Technologies"  
}

put /twitter/Company/3  
{  
"manufacturer": "Technologies"  
}

put /twitter/Company/4  
{  
"manufacturer": "ABC DEF"  
}

**My document mappings are formed dynamically.**

Now when I search,

GET /twitter/Company/\_search  
{  
"query": {  
"match": {  
"manufacturer": "Technologies"  
}  
}  
}

I get a response as below,  
"manufacturer": "ABC Technologies"  
"manufacturer": "DEF Technologies"  
"manufacturer": "Technologies"

But my requirement is to fetch only,  
"manufacturer": "Technologies"

If I'm not wrong, this Elasticsearch's behavior due to inverted indexing & standard analyzer.

I tried setting "keyword" analyzer for all string fields in dynamic\_template as below,  
PUT twitter  
{  
"mappings": {  
"_default_": {  
"dynamic\_templates": [  
{  
"string\_analyzer": {  
"match\_mapping\_type": "string",  
"match": "\*",  
"mapping": {  
"type": "string",  
"analyzer": "keyword"  
}  
}  
}  
]  
}  
}  
}

It's working fine 🙂

**Questions:**

1. What are cons of using "keyword" analyzer (90% of my fields are string type and I can't pre-define my fields as my use case is dynamic json structure) ?
2. Is there any better way to achieve my requirement?

Regards,  
Sreeram

---

<div class="post-metadata">

**Author:** ![yeikel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yeikel/32/125434_2.png) [@yeikel](https://discuss.elastic.co/u/yeikel)\
**Post date:** [October 3, 2016, 5:27pm UTC](https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093/2 "2016-10-03T17:27:58Z")

</div>

Take a look at this document : [https://www.elastic.co/guide/en/elasticsearch/guide/current/aggregations-and-analysis.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/aggregations-and-analysis.html)

Your field needs to be "not analyzed"

---

<div class="post-metadata">

**Author:** ![basharz](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@basharz](https://discuss.elastic.co/u/basharz)\
**Post date:** [October 3, 2016, 8:08pm UTC](https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093/3 "2016-10-03T20:08:13Z")

</div>

try the below mapping it should work with you, the query you should use after you apply the new mapping is:  
GET masterdatafinal/\_search  
{  
"query": {  
"match": {  
"company.raw": "Technologies"  
}  
}  
}  
just keep in your mind 2 things,  
1- this query will be case senstive  
2- you should reindex your data to get result.

PUT twitter/\_mapping/doc  
{  
"properties": {  
"company": {  
"type": "string",  
"analyzer": "english",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed"  
} } }}}

---

<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:15pm UTC](https://discuss.elastic.co/t/elasticsearch-full-text-or-exact-value-search/62093/4 "2017-07-05T22:15:19Z")

</div>


