# Exact Text Search

**URL:** <https://discuss.elastic.co/t/exact-text-search/9308>\
**Category:** Elasticsearch\
**Created:** [October 10, 2012, 2:38pm UTC](https://discuss.elastic.co/t/exact-text-search/9308 "2012-10-10T14:38:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 10, 2012, 2:38pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/1 "2012-10-10T14:38:40Z")

</div>

Hello All,

How to perform an\* Exact Text Search\*,

for example in the below 3 json docs how can I search for the word  
"#Twitter" which should bring only doc1 and doc2,  
"Twitter" - only doc3  
"Elastic Search" as one single word - only in doc1

{"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
messages ","Body":"this is a sample Elastic Search"}'

{"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
tweetsssssss","Body":"ElasticSearch is Awesome"}'

{"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
"Esearch","Body":"Twitter tweet , search"}'

I have tried using the Type:Phrase, and Also "Term":"Twitter "but this dint  
work.  
curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
'{"query":{"match":{"\_all":{"query":""Elastic  
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,  
Shannu.

--

---

<div class="post-metadata">

**Author:** ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)\
**Post date:** [October 10, 2012, 2:41pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/2 "2012-10-10T14:41:29Z")

</div>

Use WhitespaceAnalyzer on that field

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Wed, Oct 10, 2012 at 4:38 PM, shannu [shanmukhaveeranki@gmail.com](mailto:shanmukhaveeranki@gmail.com) wrote:

> Hello All,
> 
> How to perform an\* Exact Text Search\*,
> 
> for example in the below 3 json docs how can I search for the word  
> "#Twitter" which should bring only doc1 and doc2,  
> "Twitter" - only doc3  
> "Elastic Search" as one single word - only in doc1
> 
> {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> messages ","Body":"this is a sample Elastic Search"}'
> 
> {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> tweetsssssss","Body":"Elasticsearch is Awesome"}'
> 
> {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> "Esearch","Body":"Twitter tweet , search"}'
> 
> I have tried using the Type:Phrase, and Also "Term":"Twitter "but this  
> dint work.  
> curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> '{"query":{"match":{"\_all":{"query":""Elastic  
> Search"","type":"phrase"}}}}'
> 
> Any help would be much appreciated.
> 
> Cheers,  
> Shannu.
> 
> --

--

---

<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 10, 2012, 2:47pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/3 "2012-10-10T14:47:29Z")

</div>

You have to change your mapping to index Body as " index":"not\_analyzed"

See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)  
[http://www.elasticsearch.org/guide/reference/mapping/core-types.html](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)

Le 10 octobre 2012 à 16:38, shannu [shanmukhaveeranki@gmail.com](mailto:shanmukhaveeranki@gmail.com) a écrit :

> Hello All,
> 
> How to perform an Exact Text Search,
> 
> for example in the below 3 json docs how can I search for the word  
> "#Twitter" which should bring only doc1 and doc2,  
> "Twitter" - only doc3  
> "Elastic Search" as one single word - only in doc1
> 
> {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> messages ","Body":"this is a sample Elastic Search"}'
> 
> {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> tweetsssssss","Body":"Elasticsearch is Awesome"}'
> 
> {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> "Esearch","Body":"Twitter tweet , search"}'
> 
> I have tried using the Type:Phrase, and Also "Term":"Twitter "but this dint  
> work.  
> curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> '{"query":{"match":{"\_all":{"query":""Elastic Search"","type":"phrase"}}}}'
> 
> Any help would be much appreciated.
> 
> Cheers,  
> Shannu.
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<div class="post-metadata">

**Author:** ![Itamar\_Syn\_Hershko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/itamar_syn_hershko/32/725_2.png) [@Itamar\_Syn\_Hershko](https://discuss.elastic.co/u/Itamar_Syn_Hershko)\
**Post date:** [October 10, 2012, 2:51pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/4 "2012-10-10T14:51:15Z")

</div>

David. that will not work, he will have to search for the entire field to  
find a result, e.g. "query": "Elasticsearch is Awesome".

On Wed, Oct 10, 2012 at 4:47 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> \*\*  
> You have to change your mapping to index Body as " index":"not\_analyzed"
> 
> See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> 
> Le 10 octobre 2012 à 16:38, shannu [shanmukhaveeranki@gmail.com](mailto:shanmukhaveeranki@gmail.com) a  
> écrit :
> 
> Hello All,
> 
> How to perform an \* Exact Text Search\*,
> 
> for example in the below 3 json docs how can I search for the word  
> "#Twitter" which should bring only doc1 and doc2,  
> "Twitter" - only doc3  
> "Elastic Search" as one single word - only in doc1
> 
> {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> messages ","Body":"this is a sample Elastic Search"}'
> 
> {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> tweetsssssss","Body":"Elasticsearch is Awesome"}'
> 
> {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> "Esearch","Body":"Twitter tweet , search"}'
> 
> I have tried using the Type:Phrase, and Also "Term":"Twitter "but this  
> dint work.  
> curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> '{"query":{"match":{"\_all":{"query":""Elastic  
> Search"","type":"phrase"}}}}'
> 
> Any help would be much appreciated.
> 
> Cheers,  
> Shannu.
> 
> --
> 
> --  
> David Pilato  
> [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 10, 2012, 2:57pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/5 "2012-10-10T14:57:30Z")

</div>

Hi Guys,

I have tried the below query and it DINT work ☹

curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
'{"query":{"match":{"\_all":{"query":""Elastic  
Search"","type":"phrase"},"\_analyzer":"whitespace"}}}'

Apologize if I am doing a blunder here, and also would like to use "\_all"  
as my field.

Cheers,  
Shannu.

On Wednesday, October 10, 2012 3:51:19 PM UTC+1, Itamar Syn-Hershko wrote:

> David. that will not work, he will have to search for the entire field to  
> find a result, e.g. "query": "Elasticsearch is Awesome".
> 
> On Wed, Oct 10, 2012 at 4:47 PM, David Pilato \<[da...@pilato.fr](mailto:da...@pilato.fr)\<javascript:\>
> 
> > wrote:
> 
> > \*\*  
> > You have to change your mapping to index Body as " index":"not\_analyzed"
> > 
> > See  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> > 
> > Le 10 octobre 2012 à 16:38, shannu \<[shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) \<javascript:\>\>  
> > a écrit :
> > 
> > Hello All,
> > 
> > How to perform an \* Exact Text Search\*,
> > 
> > for example in the below 3 json docs how can I search for the word  
> > "#Twitter" which should bring only doc1 and doc2,  
> > "Twitter" - only doc3  
> > "Elastic Search" as one single word - only in doc1
> > 
> > {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > messages ","Body":"this is a sample Elastic Search"}'
> > 
> > {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > tweetsssssss","Body":"Elasticsearch is Awesome"}'
> > 
> > {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> > "Esearch","Body":"Twitter tweet , search"}'
> > 
> > I have tried using the Type:Phrase, and Also "Term":"Twitter "but this  
> > dint work.  
> > curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> > '{"query":{"match":{"\_all":{"query":""Elastic  
> > Search"","type":"phrase"}}}}'
> > 
> > Any help would be much appreciated.
> > 
> > Cheers,  
> > Shannu.
> > 
> > --
> > 
> > --  
> > David Pilato  
> > [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Benoit](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Benoit](https://discuss.elastic.co/u/Benoit)\
**Post date:** [October 10, 2012, 4:02pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/6 "2012-10-10T16:02:15Z")

</div>

Hi,

Itamar mean you need to use WhitespaceAnalyzer at index time. The standard  
analyzer tokenize on whitespace and on symbol and so remove them.

You can test the behavior or analyzer by using Analyze API

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Regards.

Benoît

On Wednesday, October 10, 2012 4:57:30 PM UTC+2, shannu wrote:

> Hi Guys,
> 
> I have tried the below query and it DINT work ☹
> 
> curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> '{"query":{"match":{"\_all":{"query":""Elastic  
> Search"","type":"phrase"},"\_analyzer":"whitespace"}}}'
> 
> Apologize if I am doing a blunder here, and also would like to use "\_all"  
> as my field.
> 
> Cheers,  
> Shannu.
> 
> On Wednesday, October 10, 2012 3:51:19 PM UTC+1, Itamar Syn-Hershko wrote:
> 
> > David. that will not work, he will have to search for the entire field to  
> > find a result, e.g. "query": "Elasticsearch is Awesome".
> > 
> > On Wed, Oct 10, 2012 at 4:47 PM, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> > 
> > > \*\*  
> > > You have to change your mapping to index Body as " index":"not\_analyzed"
> > > 
> > > See  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> > > 
> > > Le 10 octobre 2012 à 16:38, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) a écrit :
> > > 
> > > Hello All,
> > > 
> > > How to perform an \* Exact Text Search\*,
> > > 
> > > for example in the below 3 json docs how can I search for the word  
> > > "#Twitter" which should bring only doc1 and doc2,  
> > > "Twitter" - only doc3  
> > > "Elastic Search" as one single word - only in doc1
> > > 
> > > {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > > messages ","Body":"this is a sample Elastic Search"}'
> > > 
> > > {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > > tweetsssssss","Body":"Elasticsearch is Awesome"}'
> > > 
> > > {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> > > "Esearch","Body":"Twitter tweet , search"}'
> > > 
> > > I have tried using the Type:Phrase, and Also "Term":"Twitter "but this  
> > > dint work.  
> > > curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> > > '{"query":{"match":{"\_all":{"query":""Elastic  
> > > Search"","type":"phrase"}}}}'
> > > 
> > > Any help would be much appreciated.
> > > 
> > > Cheers,  
> > > Shannu.
> > > 
> > > --
> > > 
> > > --  
> > > David Pilato  
> > > [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> > > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > --

--

---

<div class="post-metadata">

**Author:** ![shannu](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@shannu](https://discuss.elastic.co/u/shannu)\
**Post date:** [October 10, 2012, 4:40pm UTC](https://discuss.elastic.co/t/exact-text-search/9308/7 "2012-10-10T16:40:11Z")

</div>

Hi Guys,

I've came across a good article:  
[http://paulsabou.com/blog/2012/03/25/advanced-exact-matching-with-elastic-search/](http://paulsabou.com/blog/2012/03/25/advanced-exact-matching-with-elastic-search/)

As mentinoed in the article: "_configure the index schema so that the  
“name” field is never tokenized_"

Is it a good thing to configure the index schema so that the "\_source"  
field is never tokenized ???

willl this work for the Exact Text search ?

Cheers,  
Shannu.

On Wednesday, October 10, 2012 3:57:30 PM UTC+1, shannu wrote:

> Hi Guys,
> 
> I have tried the below query and it DINT work ☹
> 
> curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> '{"query":{"match":{"\_all":{"query":""Elastic  
> Search"","type":"phrase"},"\_analyzer":"whitespace"}}}'
> 
> Apologize if I am doing a blunder here, and also would like to use "\_all"  
> as my field.
> 
> Cheers,  
> Shannu.
> 
> On Wednesday, October 10, 2012 3:51:19 PM UTC+1, Itamar Syn-Hershko wrote:
> 
> > David. that will not work, he will have to search for the entire field to  
> > find a result, e.g. "query": "Elasticsearch is Awesome".
> > 
> > On Wed, Oct 10, 2012 at 4:47 PM, David Pilato [da...@pilato.fr](mailto:da...@pilato.fr) wrote:
> > 
> > > \*\*  
> > > You have to change your mapping to index Body as " index":"not\_analyzed"
> > > 
> > > See  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)
> > > 
> > > Le 10 octobre 2012 à 16:38, shannu [shanmukh...@gmail.com](mailto:shanmukh...@gmail.com) a écrit :
> > > 
> > > Hello All,
> > > 
> > > How to perform an \* Exact Text Search\*,
> > > 
> > > for example in the below 3 json docs how can I search for the word  
> > > "#Twitter" which should bring only doc1 and doc2,  
> > > "Twitter" - only doc3  
> > > "Elastic Search" as one single word - only in doc1
> > > 
> > > {"Name": "Doc1","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > > messages ","Body":"this is a sample Elastic Search"}'
> > > 
> > > {"Name": "Doc2","postDate": "2012-10-10T12:29:00","Category": "#Twitter  
> > > tweetsssssss","Body":"Elasticsearch is Awesome"}'
> > > 
> > > {"Name": "Doc3","postDate": "2012-10-10T12:29:00","Category":  
> > > "Esearch","Body":"Twitter tweet , search"}'
> > > 
> > > I have tried using the Type:Phrase, and Also "Term":"Twitter "but this  
> > > dint work.  
> > > curl -XGET '[http://localhost:9200/Index/Type/\_search?pretty=true](http://localhost:9200/Index/Type/_search?pretty=true)' -d  
> > > '{"query":{"match":{"\_all":{"query":""Elastic  
> > > Search"","type":"phrase"}}}}'
> > > 
> > > Any help would be much appreciated.
> > > 
> > > Cheers,  
> > > Shannu.
> > > 
> > > --
> > > 
> > > --  
> > > David Pilato  
> > > [http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
> > > [http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
> > > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > > 
> > > --

--

---

<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, 3:09am UTC](https://discuss.elastic.co/t/exact-text-search/9308/8 "2017-07-06T03:09:23Z")

</div>


