lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grant Ingersoll <gsing...@apache.org>
Subject Re: Constant Score Queries and Function Queries
Date Mon, 26 Oct 2009 11:04:46 GMT

On Oct 25, 2009, at 2:36 PM, Chris Hostetter wrote:

>
> : Fair enough, I guess I was just kind of expecting a constant score  
> query + a
> : function query to result in a score of whatever the function query  
> is.  This
> : is a common trick to sort by a function, but it's easy enough to  
> just ^0 the
> : non function clause.
>
> I think the root of hte issue is that a ConstantScoreQuery has a  
> constant
> according to it's boost, which defaults to "1", so all the usual
> queryNorm effects apply when using it in a BooleanQuery.
>
> Random thought: one way to implement "sort by function" more naturally
> would be to add a "sortfunc" parm that used the FunctionQParser,  
> take the
> "q" query and move it to the Filter query list, then use the func  
> query as
> your main query.  (all of this could be triggered my a new magic sort
> field "_func_ desc" which was equivilent to "score desc" after the
> query swapping ... things like "sort=inStock desc, _func_ desc" would
> still work as well)
>

I think, longer term, we will want a lot more capabilities with  
Functions.  I know on several occasions already I have wanted them as  
stand alone fields returned with a document.  So, if that exists, then  
it is logical to sort by them as well.

FWIW, I'd also like to be able to apply functions across a whole doc  
set and return the results (functions like accumulators and  
aggregators, as well as more complex math).  Imagine being able to say  
"what's the total amount of profit to be earned if I sell all of my  
'red shirts'".  We can do some of this now with the StatsComponent,  
but it isn't the same.

Mime
View raw message