# Searching for text combinations

**URL:** <https://discuss.elastic.co/t/searching-for-text-combinations/113160>\
**Category:** Elasticsearch\
**Created:** [December 25, 2017, 6:26pm UTC](https://discuss.elastic.co/t/searching-for-text-combinations/113160 "2017-12-25T18:26:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paddy\_Mahadeva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paddy_mahadeva/32/44225_2.png) [@Paddy\_Mahadeva](https://discuss.elastic.co/u/Paddy_Mahadeva)\
**Post date:** [December 25, 2017, 6:26pm UTC](https://discuss.elastic.co/t/searching-for-text-combinations/113160/1 "2017-12-25T18:26:04Z")

</div>

Hi,

I have a problem i know is definitely not unique, but I am trying to figure what is the smartest way to do this.

I have a name field in my index "name"

the data in it could be

John Doe

john doe

JOHN DOE

doe JOHN

john mathew doe

any such, I need to run a search on the words john and doe and get all these results. Whats the best way to do this and can I do this with the keyword field or text is the only option?

Currently, I am trying to work with match option. Is there a smarter way to do it?

---

<div class="post-metadata">

**Author:** ![shanec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shanec/32/4004_2.png) [@shanec](https://discuss.elastic.co/u/shanec)\
**Post date:** [December 26, 2017, 4:37pm UTC](https://discuss.elastic.co/t/searching-for-text-combinations/113160/2 "2017-12-26T16:37:53Z")

</div>

You've got the right idea!

As a general rule of thumb:

1. Any time you think of "any/some of the words" as part of a requirement, it means it's text that's going to need to be tokenized into words, which means you're going to want the `text` type.
2. Any time you think of "must match the value in the field exactly," then you probably don't need tokenization and therefore `keyword` is likely a better match.

As some extensions to those that tend to come up next:

1. If you want to match a _phrase_ within a bigger chunk of text (e.g. match `"brown fox"` exactly within `quick brown fox jumps`) you still want `text`, but you may want to start looking at the phrase queries in Elasticsearch
2. If you _just_ want to be case insensitive but otherwise match a field value exactly, you can use a `keyword` with a [`normalizer`](https://www.elastic.co/guide/en/elasticsearch/reference/current/normalizer.html)

But you're on the right track right now!

---

<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:** [January 23, 2018, 4:37pm UTC](https://discuss.elastic.co/t/searching-for-text-combinations/113160/3 "2018-01-23T16:37:54Z")

</div>

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