You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Satish Talim <sa...@gmail.com> on 2011/10/04 16:02:23 UTC

Analyzer Tokenizer for Exact and Contains search on single field

I am a Solr newbie.

Let's say we have a field with 4 records as follows:

"James"
"James Edward"
"James Edward Gray"
"JamesEdward"

a. In Solr 3.4, I want an exact search on the given field for "James
Edward". Record 2 should be returned.

b. Next on the same field, I want to check whether "James" is contained in
the field, then records 1, 2 and 3 should be returned.

Which standard analyzer, tokenizer can one apply on one single field, to get
these results?

Satish

RE: Analyzer Tokenizer for Exact and Contains search on single field

Posted by Steven A Rowe <sa...@syr.edu>.
Hi Satish,

I don't think there is a single analyzer that does what you want.

However, you could send the info to a second field with copyField, and use e.g. WhitespaceTokenizer on one field for contains-style queries, and KeywordTokenizer on the other field (or just use the "string" field type) for exact matches.

Steve

> -----Original Message-----
> From: Satish Talim [mailto:satish.talim@gmail.com]
> Sent: Tuesday, October 04, 2011 10:02 AM
> To: solr-user@lucene.apache.org
> Subject: Analyzer Tokenizer for Exact and Contains search on single field
> 
> I am a Solr newbie.
> 
> Let's say we have a field with 4 records as follows:
> 
> "James"
> "James Edward"
> "James Edward Gray"
> "JamesEdward"
> 
> a. In Solr 3.4, I want an exact search on the given field for "James
> Edward". Record 2 should be returned.
> 
> b. Next on the same field, I want to check whether "James" is contained
> in
> the field, then records 1, 2 and 3 should be returned.
> 
> Which standard analyzer, tokenizer can one apply on one single field, to
> get
> these results?
> 
> Satish