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 bhaskar chandrasekar <ba...@yahoo.co.in> on 2009/08/25 07:10:28 UTC

Exact word search

Hi,
 
Can any one helpe me with the below scenario?.
 
Scenario 1:
 
Assume that I give Google as input string 
i am using Carrot with Solr 
Carrot is for front end display purpose 
the issue is 
Assuming i give "BHASKAR" as input string 
It should give me search results pertaining to BHASKAR only.
 Select * from MASTER where name ="Bhaskar";
 Example:It should not display search results as "ChandarBhaskar" or
 "BhaskarC".
 Should display Bhaskar only.
 
Scenario 2:
 Select * from MASTER where name like "%BHASKAR%";
 It should display records containing the word BHASKAR
 Ex: Bhaskar
ChandarBhaskar
 BhaskarC
 Bhaskarabc

 How to achieve Scenario 1 in Solr ?.



...
 
Regards
Bhaskar



      

Re: Exact word search

Posted by Shalin Shekhar Mangar <sh...@gmail.com>.
On Tue, Aug 25, 2009 at 10:40 AM, bhaskar chandrasekar <bas_sree@yahoo.co.in
> wrote:

> Hi,
>
> Can any one helpe me with the below scenario?.
>
> Scenario 1:
>
> Assume that I give Google as input string
> i am using Carrot with Solr
> Carrot is for front end display purpose


It seems like Carrot is the one making the queries to Solr? In that case,
this question may be better suited for carrot users/developers.


>
> the issue is
> Assuming i give "BHASKAR" as input string
> It should give me search results pertaining to BHASKAR only.
>  Select * from MASTER where name ="Bhaskar";
>  Example:It should not display search results as "ChandarBhaskar" or
>  "BhaskarC".
>  Should display Bhaskar only.
>


That is easy with Solr, make a query like field-name:"Bhaskar". Make sure
that field name is not tokenized i.e. string type in schema.xml


>
> Scenario 2:
>  Select * from MASTER where name like "%BHASKAR%";
>  It should display records containing the word BHASKAR
>  Ex: Bhaskar
> ChandarBhaskar
>  BhaskarC
>  Bhaskarabc
>

Leading wildcards are not supported. However there are alternate ways of
doing it.

Create two fields, keep one as a normal string type and use a
KeywordTokenizer and ReverseFilter on the other. Make one field a copyField
of the other. Perform a prefix search on both fields.

-- 
Regards,
Shalin Shekhar Mangar.