Exact Match in String field


(shannu) #1

Hello All,

I would like to perform EXACT Match (Example Search : "Firstname Lastname")
in a String field "ArticleBody" where the value of the field is a big
chunk of text
and within in this text I would like to perform the exact
match.

I came across couple of links:

http://paulsabou.com/blog/2012/03/25/advanced-exact-matching-with-elastic-search/
http://gauth.fr/2012/08/exact-search-with-elasticsearch/

which explains that if we change the mapping of the filed to
"not_analyzed", then the entire field value will be considered as one
string and I understand that this will only work where the field values are
2-3 words and wanted to be considered as one single term.

But in my case the Field "ArticleBody" will contain a very big chunk of
text(I dont want to treat the entire body of the article as single string)
and would like to find specific keywords(like: "Elastic Search", "Firstname
Lastname") within this text.

Can this be done ? Please shed some light on this.

Many thanks in advance,
Shannu.

--


(Ivan Brusic) #2

There are a few ways to achieve what you want.

First of all, all the concepts related to search stem from Lucene. You can
learn more about searching in ElasticSearch, but reading about Lucene.

Second, is case important to you? Your goal is to create an analyzer that
creates tokens that helps you achieve your queries. This could entail not
lowercasing, stemming, and removing stop words.

Easiest way is using phrase queries:
http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html Make
sure you use a correct analyzer.

You can also using span queries with a slop of 0:
http://www.elasticsearch.org/guide/reference/query-dsl/span-near-query.html

--
Ivan

On Mon, Nov 5, 2012 at 7:26 AM, shannu shanmukhaveeranki@gmail.com wrote:

Hello All,

I would like to perform EXACT Match (Example Search : "Firstname
Lastname") in a String field "ArticleBody" where the value of the field
is a big chunk of text
and within in this text I would like to perform
the exact match.

I came across couple of links:

http://paulsabou.com/blog/2012/03/25/advanced-exact-matching-with-elastic-search/
http://gauth.fr/2012/08/exact-search-with-elasticsearch/

which explains that if we change the mapping of the filed to
"not_analyzed", then the entire field value will be considered as one
string and I understand that this will only work where the field values are
2-3 words and wanted to be considered as one single term.

But in my case the Field "ArticleBody" will contain a very big chunk of
text(I dont want to treat the entire body of the article as single string)
and would like to find specific keywords(like: "Elastic Search", "Firstname
Lastname") within this text.

Can this be done ? Please shed some light on this.

Many thanks in advance,
Shannu.

--

--


(shannu) #3

Hey Ivan,

Thanks a lot for the reply and very good information.

Regards,
Shannu.

On Monday, November 5, 2012 5:21:20 PM UTC, Ivan Brusic wrote:

There are a few ways to achieve what you want.

First of all, all the concepts related to search stem from Lucene. You can
learn more about searching in ElasticSearch, but reading about Lucene.

Second, is case important to you? Your goal is to create an analyzer that
creates tokens that helps you achieve your queries. This could entail not
lowercasing, stemming, and removing stop words.

Easiest way is using phrase queries:
http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html Make
sure you use a correct analyzer.

You can also using span queries with a slop of 0:
http://www.elasticsearch.org/guide/reference/query-dsl/span-near-query.html

--
Ivan

On Mon, Nov 5, 2012 at 7:26 AM, shannu <shanmukh...@gmail.com<javascript:>

wrote:

Hello All,

I would like to perform EXACT Match (Example Search : "Firstname
Lastname") in a String field "ArticleBody" where the value of the field
is a big chunk of text
and within in this text I would like to perform
the exact match.

I came across couple of links:

http://paulsabou.com/blog/2012/03/25/advanced-exact-matching-with-elastic-search/
http://gauth.fr/2012/08/exact-search-with-elasticsearch/

which explains that if we change the mapping of the filed to
"not_analyzed", then the entire field value will be considered as one
string and I understand that this will only work where the field values are
2-3 words and wanted to be considered as one single term.

But in my case the Field "ArticleBody" will contain a very big chunk of
text(I dont want to treat the entire body of the article as single string)
and would like to find specific keywords(like: "Elastic Search", "Firstname
Lastname") within this text.

Can this be done ? Please shed some light on this.

Many thanks in advance,
Shannu.

--

--


(system) #4