# How to match a word which includes white spaces?

**URL:** <https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655>\
**Category:** Elasticsearch\
**Created:** [October 29, 2020, 8:10am UTC](https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655 "2020-10-29T08:10:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![taichi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/taichi/32/46431_2.png) [@taichi](https://discuss.elastic.co/u/taichi)\
**Post date:** [October 29, 2020, 8:10am UTC](https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655/1 "2020-10-29T08:10:01Z")

</div>

I have a text field named `profile` (with default analyzer), and I want to query with words including white spaces.  
For example, when I wanted to search by `vice president`, I created a query

```
{
    "query": {
        {
            "match": {
                "profile": {
                    "query": "vice president"
                }
            }
        }
    }
}

```

I expected I got only documents which have profiles like `I am a vice president. Thank you.`, but I also got documents whose profiles have only words `vice` **or** `president` (profile like `I am the president.`).

How to get only documents which includes adjacent words of `vice president` ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 29, 2020, 9:20am UTC](https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655/2 "2020-10-29T09:20:13Z")

</div>

This?

> **[Match phrase query | Elasticsearch Reference \[7.9\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html)**

---

<div class="post-metadata">

**Author:** ![taichi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/taichi/32/46431_2.png) [@taichi](https://discuss.elastic.co/u/taichi)\
**Post date:** [October 29, 2020, 9:51am UTC](https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655/3 "2020-10-29T09:51:22Z")

</div>

I think this is! Thank you  
(I'm a Japanese (which does not have white spaces between words) user so not familiar with this kind of query for English...)

---

<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:** [November 26, 2020, 9:51am UTC](https://discuss.elastic.co/t/how-to-match-a-word-which-includes-white-spaces/253655/4 "2020-11-26T09:51:26Z")

</div>

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