Trying to avoid filtering on score, as I'm told that's bad

classic Classic list List threaded Threaded
3 messages Options
mcb
Reply | Threaded
Open this post in threaded view
|

Trying to avoid filtering on score, as I'm told that's bad

mcb
I have a function query that returns miles as a score along two points:

q={!func}sub(sum(geodist(OriginCoordinates,39,-105),geodist(DestinationCoordinates,36,-97),Mileage),1000)

The issue that I'm having now now my results give me a list of scores:
score:10.1 (mi)
score: 20 (mi)
score: 75 (mi)

But I would like to also add a clause that cuts off the results after X miles (say 50) so that 75 above would not be included in the results. Unfortunately I can't say fq=score:[0 TO 50], but perhaps there is another way? I'm on solr 4.0

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Trying to avoid filtering on score, as I'm told that's bad

Yonik Seeley-2-2
On Wed, Jun 27, 2012 at 6:50 PM, mcb <[hidden email]> wrote:

> I have a function query that returns miles as a score along two points:
>
> q={!func}sub(sum(geodist(OriginCoordinates,39,-105),geodist(DestinationCoordinates,36,-97),Mileage),1000)
>
> The issue that I'm having now now my results give me a list of scores:
> *score:10.1 (mi)
> score: 20 (mi)
> score: 75 (mi)
> *
> But I would like to also add a clause that cuts off the results after X
> miles (say 50) so that 75 above would not be included in the results.
> Unfortunately I can't say fq=score:[0 TO 50], but perhaps there is another
> way? I'm on solr 4.0

If you want to cut off the whole function at 75, then frange can do that:
q={!frange u=75}sub(sum(...

http://lucene.apache.org/solr/api/org/apache/solr/search/FunctionRangeQParserPlugin.html

-Yonik
http://lucidimagination.com
mcb
Reply | Threaded
Open this post in threaded view
|

Re: Trying to avoid filtering on score, as I'm told that's bad

mcb
Thanks, this worked using:

&qq={!func}sub(sum(geodist(pt1,30.271567,-97.741886),geodist(pt2,36.054889,-95.716187),product(1.609344, Dist)), 1000) asc

&sort=$qq

&fq={!frange u=100}$qq