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 Michael Owen <mi...@hotmail.com> on 2011/04/15 17:50:19 UTC
Sort by function - 400 error
Using solr 3.1.
When I do:
sort=score desc
it works.
sort=product(typeId,2) desc (typeId is a valid attribute in document)
it works.
sort=product(score,typeId) desc
fails on 400 error? Also "sort=product(score,2) desc" fails too.
Must be something basic I'm missing? Tried adding &fl=*,score too.
Thanks
Mike
Re: Sort by function - 400 error
Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Fri, Apr 15, 2011 at 11:50 AM, Michael Owen
<mi...@hotmail.com> wrote:
>
> Using solr 3.1.
> When I do:
> sort=score desc
> it works.
> sort=product(typeId,2) desc (typeId is a valid attribute in document)
> it works.
> sort=product(score,typeId) desc
> fails on 400 error? Also "sort=product(score,2) desc" fails too.
You can't currently use "score" in function queries.
You can embed another query in a function query though.
Example:
sort=product($qq,typeId) desc&qq=my_query_here
In your case, when you just want to multiply the score by a field,
then you can either use the edismax query parser and the "boost"
parameter:
defType=edismax&q=my_query_here&boost=typeId
Or you could directly use the "boost" query parser
http://lucene.apache.org/solr/api/org/apache/solr/search/BoostQParserPlugin.html
q={!boost b=typeId}my_query_here
OR
q={!boost b=typeId v=$qq}&qq=my_query_here
-Yonik
http://www.lucenerevolution.org -- Lucene/Solr User Conference, May
25-26, San Francisco