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 Kamal Palei <pa...@gmail.com> on 2013/05/22 15:27:46 UTC

search filter

Dear All
Can I write a search filter for a field having a value in a range or a
specific value.

Say if I want to have a filter like
1. Select profiles with salary 5 to 10  or Salary 0.

So I expect profiles having salary either 0 , 5, 6, 7, 8, 9, 10 etc.

It should be possible, can somebody help me with syntax of 'fq' filter
please.

Best Regards
kamal

Re: search filter

Posted by Kamal Palei <pa...@gmail.com>.
Looks I am getting exception as below


May 22, 2013 10:52:11 PM org.apache.solr.common.SolrException log
SEVERE: java.lang.NumberFormatException: For input string: "[3 TO 9] OR
salary:0"
        at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Long.parseLong(Long.java:438)
        at java.lang.Long.parseLong(Long.java:478)


Regards
kamal


On Thu, May 23, 2013 at 11:19 AM, Kamal Palei <pa...@gmail.com> wrote:

> HI Rafał Kuć
> I tried fq=Salary:[5+TO+10]+OR+Salary:0 and as well as fq=Salary:[5 TO
> 10] OR Salary:0  both, both the cases I retrieved 0 results.
>
> I use drupal along with solr, my code looks as below.
>
> *           if($include_0_salary == 1)
>                 {
>                     $conditions['fq'][0] = 'salary:[' . $min_ctc . '+TO+'
> .
> $max_ctc . ']+OR+salary:0';
>                 }
>                 else
>                 {
>                     $conditions['fq'][0] = 'salary:[' . $min_ctc . ' TO '
> . $max_ctc . ']';
>                 }
>                 $conditions['fq'][1] = 'experience:[' . $min_exp . ' TO '
> . $max_exp . ']';
>
>                 $results = apachesolr_search_search_execute($keys,
> $conditions);
> *
> Looks when iclude_0_salary is false, I am getting results as expected.
> If iclude_0_salary is true, I get 0 results, that means for me *$conditions['fq'][0]=
> salary:[5 TO 10] OR salary:0*  did not work.
>
> Can somebody help me what the wrong I am doing here...
>
> Best regards
> kamal
>
>
>
>
> On Wed, May 22, 2013 at 7:00 PM, Rafał Kuć <r....@solr.pl> wrote:
>
>> Hello!
>>
>> You can try sending a filter like this fq=Salary:[5+TO+10]+OR+Salary:0
>>
>> It should work
>>
>> --
>> Regards,
>>  Rafał Kuć
>>  Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch -
>> ElasticSearch
>>
>> > Dear All
>> > Can I write a search filter for a field having a value in a range or a
>> > specific value.
>>
>> > Say if I want to have a filter like
>> > 1. Select profiles with salary 5 to 10  or Salary 0.
>>
>> > So I expect profiles having salary either 0 , 5, 6, 7, 8, 9, 10 etc.
>>
>> > It should be possible, can somebody help me with syntax of 'fq' filter
>> > please.
>>
>> > Best Regards
>> > kamal
>>
>>
>

Re: search filter

Posted by Gora Mohanty <go...@mimirtech.com>.
On 23 May 2013 11:19, Kamal Palei <pa...@gmail.com> wrote:
> HI Rafał Kuć
> I tried fq=Salary:[5+TO+10]+OR+Salary:0 and as well as fq=Salary:[5 TO 10]
> OR Salary:0  both, both the cases I retrieved 0 results.
[...]

Please try the suggested filter query from the
Solr admin. interface, or by typing it directly
into the browser URL bar. My guess is that
there is still some issue with your Drupal/Solr
integration.

Regards,
Gora

Re: search filter

Posted by Kamal Palei <pa...@gmail.com>.
HI Rafał Kuć
I tried fq=Salary:[5+TO+10]+OR+Salary:0 and as well as fq=Salary:[5 TO 10]
OR Salary:0  both, both the cases I retrieved 0 results.

I use drupal along with solr, my code looks as below.

*           if($include_0_salary == 1)
                {
                    $conditions['fq'][0] = 'salary:[' . $min_ctc . '+TO+' .
$max_ctc . ']+OR+salary:0';
                }
                else
                {
                    $conditions['fq'][0] = 'salary:[' . $min_ctc . ' TO ' .
$max_ctc . ']';
                }
                $conditions['fq'][1] = 'experience:[' . $min_exp . ' TO ' .
$max_exp . ']';

                $results = apachesolr_search_search_execute($keys,
$conditions);
*
Looks when iclude_0_salary is false, I am getting results as expected.
If iclude_0_salary is true, I get 0 results, that means for me
*$conditions['fq'][0]=
salary:[5 TO 10] OR salary:0*  did not work.

Can somebody help me what the wrong I am doing here...

Best regards
kamal




On Wed, May 22, 2013 at 7:00 PM, Rafał Kuć <r....@solr.pl> wrote:

> Hello!
>
> You can try sending a filter like this fq=Salary:[5+TO+10]+OR+Salary:0
>
> It should work
>
> --
> Regards,
>  Rafał Kuć
>  Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
>
> > Dear All
> > Can I write a search filter for a field having a value in a range or a
> > specific value.
>
> > Say if I want to have a filter like
> > 1. Select profiles with salary 5 to 10  or Salary 0.
>
> > So I expect profiles having salary either 0 , 5, 6, 7, 8, 9, 10 etc.
>
> > It should be possible, can somebody help me with syntax of 'fq' filter
> > please.
>
> > Best Regards
> > kamal
>
>

Re: search filter

Posted by Rafał Kuć <r....@solr.pl>.
Hello!

You can try sending a filter like this fq=Salary:[5+TO+10]+OR+Salary:0

It should work

-- 
Regards,
 Rafał Kuć
 Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch

> Dear All
> Can I write a search filter for a field having a value in a range or a
> specific value.

> Say if I want to have a filter like
> 1. Select profiles with salary 5 to 10  or Salary 0.

> So I expect profiles having salary either 0 , 5, 6, 7, 8, 9, 10 etc.

> It should be possible, can somebody help me with syntax of 'fq' filter
> please.

> Best Regards
> kamal