# Search for exact phrase in not\_analyzed (keyword) field

**URL:** <https://discuss.elastic.co/t/search-for-exact-phrase-in-not-analyzed-keyword-field/178198>\
**Category:** Elasticsearch\
**Created:** [April 24, 2019, 9:05am UTC](https://discuss.elastic.co/t/search-for-exact-phrase-in-not-analyzed-keyword-field/178198 "2019-04-24T09:05:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ckdot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ckdot/32/44698_2.png) [@ckdot](https://discuss.elastic.co/u/ckdot)\
**Post date:** [April 24, 2019, 9:05am UTC](https://discuss.elastic.co/t/search-for-exact-phrase-in-not-analyzed-keyword-field/178198/1 "2019-04-24T09:05:43Z")

</div>

Hey there,

I like to search for an exact phrase of words in my documents. To have a document be part of the search results the phrase should be somewhere in the searched fields.

My fields have type "keyword" as I don't want to have any analyzing done before and the search should search the original string.

Let's assume the field value of some document is "ElasticSearch is a popular search engine".  
The following searches should return/not return the document.

"ElasticSearch" =\> return  
"ElasticSearch is" =\> return  
"popular search" =\> return  
"popular engine" =\> not return  
"is popular" =\> not return

I tried the following query, all of them without success. Either no results will be returned or too many. It seems like query\_string indeed splits for whitespace even if the doc for my understand says it doesn't ("Whitespaces are not considered operators..."):

```
"query_string": {
   "fields": ["search_fields.name.raw"],
    "query": "*ElasticSearch is*"
}

"query_string": {
   "fields": ["search_fields.name.raw"],
    "query": "*\"ElasticSearch is\"*"
}

```

(I know wildcards . at the beginning are not performant - I'll tackle that later).

The question was already asked here like 7 years ago but there was no working answer posted:  
[http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html](http://elasticsearch-users.115913.n3.nabble.com/Wildcards-in-exact-phrase-in-query-string-search-td4020826.html)

What could also be relevant: I don't know all the fields before so I use dynamic\_templates and multi\_match/query\_string to search through multiple fields inside an object.

I'd appreciate if someone could give me hints how to solve that.

Thanks  
Christian

---

<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:** [May 22, 2019, 9:06am UTC](https://discuss.elastic.co/t/search-for-exact-phrase-in-not-analyzed-keyword-field/178198/2 "2019-05-22T09:06:02Z")

</div>

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