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 Mark Smith <ma...@yahoo.com> on 2013/04/09 07:15:56 UTC

conditional queries?

Hi,

Is it possible to do a conditional query if another query has no results?  For example, say I want to search against a given field for:

- Search for "car".  If there are results, return them.  
- Else, search for "car*" .  If there are results, return them.  
- Else, search for "car~" .  If there are results, return them.  

Is this possible in one query?  Or would I need to make 3 separate queries by implementing this logic within my client?

Thanks!
Mark


Re: conditional queries?

Posted by Miguel <mi...@juntadeandalucia.es>.
I not sure, but you can create a class extend of SearchComponent and 
include at the least of your requesthandler and in this way add optional 
actions about whatever query on your solr server.
Example solrconfig.xml
  <requestHandler
...
  <arr name="last-components">
       <str>actions</str>
     </arr>
  </requestHandler>

  <searchComponent name="actions" class=" HERE YOUR CLASS" >
     <str name="params">....</str>
   </searchComponent>

Regars

El 09/04/2013 17:05, Walter Underwood escribió:
> We do this on the client side with multiple queries. It is fairly efficient, because most responses are from the first, exact query.
>
> wunder
>
> On Apr 9, 2013, at 6:15 AM, Koji Sekiguchi wrote:
>
>> Hi Mark,
>>
>>> Is it possible to do a conditional query if another query has no results?  For example, say I want to search against a given field for:
>>>
>>> - Search for "car".  If there are results, return them.
>>> - Else, search for "car*" .  If there are results, return them.
>>> - Else, search for "car~" .  If there are results, return them.
>>>
>>> Is this possible in one query?  Or would I need to make 3 separate queries by implementing this logic within my client?
>> As far as I know, there is no such SearchComponent.
>> But the idea of "FallbackRequestHandler" has been told, see SOLR-1878, for example:
>>
>> https://issues.apache.org/jira/browse/SOLR-1878
>>
>> koji
>> -- 
>> http://soleami.com/blog/lucene-4-is-super-convenient-for-developing-nlp-tools.html
>
>
>
>
>


Re: conditional queries?

Posted by Walter Underwood <wu...@wunderwood.org>.
We do this on the client side with multiple queries. It is fairly efficient, because most responses are from the first, exact query.

wunder

On Apr 9, 2013, at 6:15 AM, Koji Sekiguchi wrote:

> Hi Mark,
> 
> > Is it possible to do a conditional query if another query has no results?  For example, say I want to search against a given field for:
>> 
>> - Search for "car".  If there are results, return them.
>> - Else, search for "car*" .  If there are results, return them.
>> - Else, search for "car~" .  If there are results, return them.
>> 
>> Is this possible in one query?  Or would I need to make 3 separate queries by implementing this logic within my client?
> 
> As far as I know, there is no such SearchComponent.
> But the idea of "FallbackRequestHandler" has been told, see SOLR-1878, for example:
> 
> https://issues.apache.org/jira/browse/SOLR-1878
> 
> koji
> -- 
> http://soleami.com/blog/lucene-4-is-super-convenient-for-developing-nlp-tools.html






Re: conditional queries?

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
Hi Mark,

 > Is it possible to do a conditional query if another query has no results?  For example, say I 
want to search against a given field for:
>
> - Search for "car".  If there are results, return them.
> - Else, search for "car*" .  If there are results, return them.
> - Else, search for "car~" .  If there are results, return them.
>
> Is this possible in one query?  Or would I need to make 3 separate queries by implementing this logic within my client?

As far as I know, there is no such SearchComponent.
But the idea of "FallbackRequestHandler" has been told, see SOLR-1878, for example:

https://issues.apache.org/jira/browse/SOLR-1878

koji
-- 
http://soleami.com/blog/lucene-4-is-super-convenient-for-developing-nlp-tools.html