Dinesh - indeed.  You can compose arbitrarily complex queries using what has 
been termed “nested queries” like this.

It used to be q=_query_:”{!…}...” OR _query_:”{!…}…”, but the _query_ trick 
isn’t strictly necessary now (though care has to be take to make sure these 
complex nested expressions parse as you expect)

See slide #12 here: http://www.slideshare.net/erikhatcher/sa-22830939 
<http://www.slideshare.net/erikhatcher/sa-22830939>

        Erik


> On Dec 5, 2014, at 11:30 AM, Dinesh Babu <dinesh.b...@pb.com> wrote:
> 
> One more quick question Erik,
> 
> If I want to do search on multiple fields using {!field} do we have a query 
> similar to what  {!prefix} has
> :  q={!prefix f=field1 v=$f1_val} OR {!prefix f=field2 v=$f2_val} where 
> &f1_val=<field 1 value>&f2_val=<field2 value>
> 
> Regards,
> Dinesh Babu.
> 
> 
> 
> -----Original Message-----
> From: Dinesh Babu
> Sent: 05 December 2014 16:26
> To: solr-user@lucene.apache.org
> Subject: RE: How to stop Solr tokenising search terms with spaces
> 
> Thanks a lot Erik. {!field} seems to solve our issue. Much appreciate your 
> help
> 
> 
> Regards,
> Dinesh Babu.
> 
> 
> 
> -----Original Message-----
> From: Erik Hatcher [mailto:erik.hatc...@gmail.com]
> Sent: 05 December 2014 16:00
> To: solr-user@lucene.apache.org
> Subject: Re: How to stop Solr tokenising search terms with spaces
> 
> try using {!field} instead of {!prefix}.  {!field} will create a phrase query 
> (or term query if it’s just one term) after analysis.  [it also could 
> construct other query types if the analysis overlaps tokens, but maybe not 
> relevant here]
> 
> Also note that you can use multiple of these expressions if needed:  
> q={!prefix f=field1 v=$f1_val} OR {!prefix f=field2 v=$f2_val} where 
> &f1_val=<field 1 value>&f2_val=<field2 value>
> 
>        Erik
> 
> 
> 
>> On Dec 5, 2014, at 10:45 AM, Dinesh Babu <dinesh.b...@pb.com> wrote:
>> 
>> Hi,
>> 
>> We are using Solr 4.10.2 to store user names from LDAP. I want Solr not to 
>> tokenise my search term which has space in it Eg: If there is a user by the 
>> name Tom Hanks Major, then
>> 
>> 1) When I do a query for " Tom Hanks Major " , I don't want solr break this 
>> search phrase and search for individual words (ie, Tom ,Hanks, Major), but 
>> search for the whole phrase and get me the Tom Hanks Major user
>> 
>> 2) Also if I query for "Hanks Major" I should get the Tom Hanks Major user 
>> back
>> 
>> We used !prefix, but that does no allow the scenario 2. Also !prefix will 
>> restrict the search to one field and can't do on mutiple fields. Any 
>> solutions?
>> 
>> Regards,
>> Dinesh Babu.
>> 
>> ________________________________
>> 
> 
> 
> ________________________________
> 

Reply via email to