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 rachun <ra...@gmail.com> on 2014/01/16 12:29:06 UTC

Query by range of price

Hi Gurus,

Please help...
I just want to query the document with price_min range and I do like this
q=...&sort=price_min asc,update_date desc&facet.query=price_min:[*+TO+1300]

I got error
'400' Status: Bad Request 

what's wrong with this?

Thank you very much.



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by Raymond Wiker <rw...@gmail.com>.
To start with, you have "+"-coded spaces in the range part, but the sort parameter has an unencoded space character.

Not sure if this is the reason that it fails, but it is certainly a reason to look closer at how you encode your queries...
 
On 16 Jan 2014, at 12:29 , rachun <ra...@gmail.com> wrote:

> Hi Gurus,
> 
> Please help...
> I just want to query the document with price_min range and I do like this
> q=...&sort=price_min asc,update_date desc&facet.query=price_min:[*+TO+1300]
> 
> I got error
> '400' Status: Bad Request 
> 
> what's wrong with this?
> 
> Thank you very much.
> 
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
Thank you very much Raymond,

I will try





--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112229.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
Hi Raymond,

I keep trying to encode the '&'  but when I look at the solar log it show me
that '%26' 
I'm using urlencode it didn't work what should i do? Please suggest me.


Thank you very much,
Rachun



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112251.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
Hi Raymond, 

I keep trying to encode the '&'  but when I look at the solar log it show me
that '%26' 
I'm using urlencode it didn't work what should i do? Im using PHPSolrClient.
Please suggest me. 

Thank you very much, 
Rachun




--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112252.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
Thank you very much Mr. Raymond

You just saved my world ;)
It's worked and *sort by conditions *
but facet.query=price_min:[* TO 1300] not working yet but I will try to
google for the right solution.

Million thanks _/|\_
Rachun.



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112272.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by Raymond Wiker <rw...@gmail.com>.
Followup: I *think* something like this should work:

$results = $solr->search($query, $start, $rows, array('sort' => 'price_min
asc,update_date desc', 'facet.query' => 'price_min:[* TO 1300]'));


On Mon, Jan 20, 2014 at 11:05 AM, Raymond Wiker <rw...@gmail.com> wrote:

> That's exactly what I would expect from url-encoding '&'. So, the thing
> that you're doing works as it should, but you're probably doing something
> that you should not do (in this case, urlencode).
>
> I have not used SolrPHPClient myself, but from the example at
> http://code.google.com/p/solr-php-client/wiki/FAQ#How_Can_I_Use_Additional_Parameters_%28like_fq,_facet,_etc%29it appears that you should not do any urlencoding yourself, at all.
> Further, if you're using data that is already urlencoded, you should
> urldecode it before handing it over to SolrPHPClient.
>
>
> On Mon, Jan 20, 2014 at 10:34 AM, rachun <ra...@gmail.com> wrote:
>
>> Hi Raymond,
>>
>> I keep trying to encode the '&'  but when I look at the solar log it show
>> me
>> that '%26'
>> I'm using urlencode it didn't work what should i do? Im using
>> SolrPHPClient.
>> Please suggest me.
>>
>> Thank you very much,
>> Rachun
>>
>>
>>
>> --
>> View this message in context:
>> http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112256.html
>> Sent from the Solr - User mailing list archive at Nabble.com.
>>
>
>

Re: Query by range of price

Posted by Raymond Wiker <rw...@gmail.com>.
That's exactly what I would expect from url-encoding '&'. So, the thing
that you're doing works as it should, but you're probably doing something
that you should not do (in this case, urlencode).

I have not used SolrPHPClient myself, but from the example at
http://code.google.com/p/solr-php-client/wiki/FAQ#How_Can_I_Use_Additional_Parameters_%28like_fq,_facet,_etc%29it
appears that you should not do any urlencoding yourself, at all.
Further, if you're using data that is already urlencoded, you should
urldecode it before handing it over to SolrPHPClient.


On Mon, Jan 20, 2014 at 10:34 AM, rachun <ra...@gmail.com> wrote:

> Hi Raymond,
>
> I keep trying to encode the '&'  but when I look at the solar log it show
> me
> that '%26'
> I'm using urlencode it didn't work what should i do? Im using
> SolrPHPClient.
> Please suggest me.
>
> Thank you very much,
> Rachun
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112256.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
Hi Raymond, 

I keep trying to encode the '&'  but when I look at the solar log it show me
that '%26' 
I'm using urlencode it didn't work what should i do? Im using SolrPHPClient. 
Please suggest me. 

Thank you very much, 
Rachun 



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4112256.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by Raymond Wiker <rw...@gmail.com>.
What Erick is saying is that the facet.query seen by solr is

price_min:[*+TO+1300]

rather than

price_min:[* TO 1300]

Having done this sort of thing myself, my guess is that you're probably
doing a urlencode operation more than you should be (on the facet.query
value).



On Fri, Jan 17, 2014 at 6:18 AM, rachun <ra...@gmail.com> wrote:

> I have no idea Mr. Eric :(
>
> thanks,
> Rachun
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4111853.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
I have no idea Mr. Eric :(

thanks,
Rachun



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4111853.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by Erick Erickson <er...@gmail.com>.
Hmmm, it looks like you have already encoded the spaces as '+' (as
Raymond pointed out). Then they're further encoded as %2B which sends
a literal plus through, which is invalid....

Best,
Erick

On Thu, Jan 16, 2014 at 9:51 PM, rachun <ra...@gmail.com> wrote:
> this is the log says:
> INFO  - 2014-01-17 09:50:14.448; org.apache.solr.core.SolrCore;
> [collection1] webapp=/solr path=/select
> params={start=0&q=???????%26sort%3Dprice_min+asc,update_date+desc%26facet.query%3Dprice_min:[*%2BTO%2B1300]&json.nl=map&wt=json&rows=100}
> status=400 QTime=2
>
> could you please point me out?
>
> Thank you very much _/|\_
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4111841.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by rachun <ra...@gmail.com>.
this is the log says:
INFO  - 2014-01-17 09:50:14.448; org.apache.solr.core.SolrCore;
[collection1] webapp=/solr path=/select
params={start=0&q=???????%26sort%3Dprice_min+asc,update_date+desc%26facet.query%3Dprice_min:[*%2BTO%2B1300]&json.nl=map&wt=json&rows=100}
status=400 QTime=2 

could you please point me out?

Thank you very much _/|\_



--
View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655p4111841.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Query by range of price

Posted by Erick Erickson <er...@gmail.com>.
What do you get in our solr logs? Because this looks reasonable....

My guess is that the URL is incorrect, but it's only a guess. Tail -f <solr log>
and submit this and you should see something interesting.

Best,
Erick

On Thu, Jan 16, 2014 at 6:29 AM, rachun <ra...@gmail.com> wrote:
> Hi Gurus,
>
> Please help...
> I just want to query the document with price_min range and I do like this
> q=...&sort=price_min asc,update_date desc&facet.query=price_min:[*+TO+1300]
>
> I got error
> '400' Status: Bad Request
>
> what's wrong with this?
>
> Thank you very much.
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Query-by-range-of-price-tp4111655.html
> Sent from the Solr - User mailing list archive at Nabble.com.