# Full text search : search phrase in text

**URL:** <https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136>\
**Category:** Elasticsearch\
**Created:** [May 27, 2013, 12:39pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136 "2013-05-27T12:39:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarang\_dawer](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tarang\_dawer](https://discuss.elastic.co/u/tarang_dawer)\
**Post date:** [May 27, 2013, 12:39pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/1 "2013-05-27T12:39:16Z")

</div>

Hi  
i am using elasticsearch for storing some text fields.  
while using white space tokenizer , the text is divided into tokens based  
on the white space separation between them , and is searchable by token  
based search only .

but , m not able to do some phrase search , like i am indexing ,  
" ELASTIC SERVER FULL TEXT SEARCH"  
i am able to search for any of the tokens in the above text , but not on  
any continuous phrase like, "ELASTIC SERVER" .

which , analyzer(tokenizer /tokenfilter) combination should be used to  
search for a phrase in the full text search.  
Could somebody please help me resolve the issue ?

Thanks  
Tarang Dawer

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![tarang\_dawer](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tarang\_dawer](https://discuss.elastic.co/u/tarang_dawer)\
**Post date:** [May 27, 2013, 3:30pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/2 "2013-05-27T15:30:02Z")

</div>

i have tried using the field query , but it returns results based on token  
match ,  
like for example , i have documents like "1. THIS IS ELASTICSEARCH"  
"ELASTICSEARCH IS AWESOME"

if i search for IS ELASTICSEARCH , both of my documents are returned as a  
search hit .

is there some way , or elasticsearch/lucene stores/maintains a certain  
positioning or ordering system , so that only THIS IS ELASTICSEARCH is  
returned ?

Also please suggest tokenizer/analyzer for the document , to be searchable  
in this way ?

Thanks  
Tarang Dawer

On Mon, May 27, 2013 at 6:09 PM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:

> Hi  
> i am using elasticsearch for storing some text fields.  
> while using white space tokenizer , the text is divided into tokens based  
> on the white space separation between them , and is searchable by token  
> based search only .
> 
> but , m not able to do some phrase search , like i am indexing ,  
> " ELASTIC SERVER FULL TEXT SEARCH"  
> i am able to search for any of the tokens in the above text , but not on  
> any continuous phrase like, "ELASTIC SERVER" .
> 
> which , analyzer(tokenizer /tokenfilter) combination should be used to  
> search for a phrase in the full text search.  
> Could somebody please help me resolve the issue ?
> 
> Thanks  
> Tarang Dawer

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [May 27, 2013, 3:44pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/3 "2013-05-27T15:44:07Z")

</div>

There are quite a few options but the easiest is to use the Match phrase  
query: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/match-query/)

Thanks,  
Matt Weber

On Mon, May 27, 2013 at 8:30 AM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:

> i have tried using the field query , but it returns results based on token  
> match ,  
> like for example , i have documents like "1. THIS IS ELASTICSEARCH"  
> "ELASTICSEARCH IS AWESOME"
> 
> if i search for IS ELASTICSEARCH , both of my documents are returned as a  
> search hit .
> 
> is there some way , or elasticsearch/lucene stores/maintains a certain  
> positioning or ordering system , so that only THIS IS ELASTICSEARCH is  
> returned ?
> 
> Also please suggest tokenizer/analyzer for the document , to be searchable  
> in this way ?
> 
> Thanks  
> Tarang Dawer
> 
> On Mon, May 27, 2013 at 6:09 PM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:
> 
> > Hi  
> > i am using elasticsearch for storing some text fields.  
> > while using white space tokenizer , the text is divided into tokens based  
> > on the white space separation between them , and is searchable by token  
> > based search only .
> > 
> > but , m not able to do some phrase search , like i am indexing ,  
> > " ELASTIC SERVER FULL TEXT SEARCH"  
> > i am able to search for any of the tokens in the above text , but not on  
> > any continuous phrase like, "ELASTIC SERVER" .
> > 
> > which , analyzer(tokenizer /tokenfilter) combination should be used to  
> > search for a phrase in the full text search.  
> > Could somebody please help me resolve the issue ?
> > 
> > Thanks  
> > Tarang Dawer
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![tarang\_dawer](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@tarang\_dawer](https://discuss.elastic.co/u/tarang_dawer)\
**Post date:** [May 27, 2013, 4:05pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/4 "2013-05-27T16:05:17Z")

</div>

Hi Matt  
Thanks for the speedy response . i 'll go through the link you provided ,  
and get back to you  
could you also please elaborate the "other options" ?

Thanks  
Tarang Dawer

On Mon, May 27, 2013 at 9:14 PM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:

> There are quite a few options but the easiest is to use the Match phrase  
> query:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/match-query/)
> 
> Thanks,  
> Matt Weber
> 
> On Mon, May 27, 2013 at 8:30 AM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:
> 
> > i have tried using the field query , but it returns results based on  
> > token match ,  
> > like for example , i have documents like "1. THIS IS ELASTICSEARCH"  
> > "ELASTICSEARCH IS AWESOME"
> > 
> > if i search for IS ELASTICSEARCH , both of my documents are returned as a  
> > search hit .
> > 
> > is there some way , or elasticsearch/lucene stores/maintains a certain  
> > positioning or ordering system , so that only THIS IS ELASTICSEARCH is  
> > returned ?
> > 
> > Also please suggest tokenizer/analyzer for the document , to be  
> > searchable in this way ?
> > 
> > Thanks  
> > Tarang Dawer
> > 
> > On Mon, May 27, 2013 at 6:09 PM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:
> > 
> > > Hi  
> > > i am using elasticsearch for storing some text fields.  
> > > while using white space tokenizer , the text is divided into tokens  
> > > based on the white space separation between them , and is searchable by  
> > > token based search only .
> > > 
> > > but , m not able to do some phrase search , like i am indexing ,  
> > > " ELASTIC SERVER FULL TEXT SEARCH"  
> > > i am able to search for any of the tokens in the above text , but not on  
> > > any continuous phrase like, "ELASTIC SERVER" .
> > > 
> > > which , analyzer(tokenizer /tokenfilter) combination should be used to  
> > > search for a phrase in the full text search.  
> > > Could somebody please help me resolve the issue ?
> > > 
> > > Thanks  
> > > Tarang Dawer
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [May 28, 2013, 4:05pm UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/5 "2013-05-28T16:05:45Z")

</div>

You can use a QueryStringQuery with a quoted phrase in the query string or  
you can enable the auto\_generate\_phrase\_queries option. There are some  
indexing techniques using Shingles as well but that is overkill for what  
you want to do.

Thanks,  
Matt Weber

On Mon, May 27, 2013 at 9:05 AM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:

> Hi Matt  
> Thanks for the speedy response . i 'll go through the link you provided ,  
> and get back to you  
> could you also please elaborate the "other options" ?
> 
> Thanks  
> Tarang Dawer
> 
> On Mon, May 27, 2013 at 9:14 PM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:
> 
> > There are quite a few options but the easiest is to use the Match phrase  
> > query:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/match-query/)
> > 
> > Thanks,  
> > Matt Weber
> > 
> > On Mon, May 27, 2013 at 8:30 AM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:
> > 
> > > i have tried using the field query , but it returns results based on  
> > > token match ,  
> > > like for example , i have documents like "1. THIS IS ELASTICSEARCH"  
> > > "ELASTICSEARCH IS AWESOME"
> > > 
> > > if i search for IS ELASTICSEARCH , both of my documents are returned as  
> > > a search hit .
> > > 
> > > is there some way , or elasticsearch/lucene stores/maintains a certain  
> > > positioning or ordering system , so that only THIS IS ELASTICSEARCH is  
> > > returned ?
> > > 
> > > Also please suggest tokenizer/analyzer for the document , to be  
> > > searchable in this way ?
> > > 
> > > Thanks  
> > > Tarang Dawer
> > > 
> > > On Mon, May 27, 2013 at 6:09 PM, Tarang Dawer [tarang.dawer@gmail.com](mailto:tarang.dawer@gmail.com)wrote:
> > > 
> > > > Hi  
> > > > i am using elasticsearch for storing some text fields.  
> > > > while using white space tokenizer , the text is divided into tokens  
> > > > based on the white space separation between them , and is searchable by  
> > > > token based search only .
> > > > 
> > > > but , m not able to do some phrase search , like i am indexing ,  
> > > > " ELASTIC SERVER FULL TEXT SEARCH"  
> > > > i am able to search for any of the tokens in the above text , but not  
> > > > on any continuous phrase like, "ELASTIC SERVER" .
> > > > 
> > > > which , analyzer(tokenizer /tokenfilter) combination should be used to  
> > > > search for a phrase in the full text search.  
> > > > Could somebody please help me resolve the issue ?
> > > > 
> > > > Thanks  
> > > > Tarang Dawer
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:34am UTC](https://discuss.elastic.co/t/full-text-search-search-phrase-in-text/12136/6 "2017-07-06T02:34:18Z")

</div>


