Exact Text Search


(shannu) #1

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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--


(Itamar Syn-Hershko) #2

Use WhitespaceAnalyzer on that field

http://www.elasticsearch.org/guide/reference/mapping/analyzer-field.html

On Wed, Oct 10, 2012 at 4:38 PM, shannu 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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

--


(David Pilato) #3

You have to change your mapping to index Body as " index":"not_analyzed"

See 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 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' -d
'{"query":{"match":{"_all":{"query":""Elastic Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

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

--


(Itamar Syn-Hershko) #4

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 wrote:

**
You have to change your mapping to index Body as " index":"not_analyzed"

See http://www.elasticsearch.org/guide/reference/mapping/core-types.html

Le 10 octobre 2012 à 16:38, shannu 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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

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

--

--


(shannu) #5

Hi Guys,

I have tried the below query and it DINT work :frowning:

curl -XGET '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<javascript:>

wrote:

**
You have to change your mapping to index Body as " index":"not_analyzed"

See
http://www.elasticsearch.org/guide/reference/mapping/core-types.html

Le 10 octobre 2012 à 16:38, shannu <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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

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

--

--


(Benoît) #6

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
http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html

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 :frowning:

curl -XGET '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 wrote:

**
You have to change your mapping to index Body as " index":"not_analyzed"

See
http://www.elasticsearch.org/guide/reference/mapping/core-types.html

Le 10 octobre 2012 à 16:38, shannu 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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

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

--

--


(shannu) #7

Hi Guys,

I've came across a good article:
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 :frowning:

curl -XGET '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 wrote:

**
You have to change your mapping to index Body as " index":"not_analyzed"

See
http://www.elasticsearch.org/guide/reference/mapping/core-types.html

Le 10 octobre 2012 à 16:38, shannu 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' -d
'{"query":{"match":{"_all":{"query":""Elastic
Search"","type":"phrase"}}}}'

Any help would be much appreciated.

Cheers,
Shannu.

--

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

--

--


(system) #8