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 gdeconto <ge...@topproducer.com> on 2009/11/24 23:18:10 UTC

how is score computed with hsin functionquery?

I was looking at functionqueries, and noticed that:

1. if I use the sum functionquery, the score in the results is the sum of
the values I want to sum (all well and good and expected):

http://127.0.0.1:8080/solr/select?q=(*:*)^0%20%20_val_:"sum(1,2,3,4,5)"&fl=score,Latitude,Longitude&sort=score%20asc

2. if I use the hsin functionquery (i.e.
hsin(45.67890,-123.456789,Latitude,Longitude,10)"</), the score in the
results is not the distance between the two points:

http://127.0.0.1:8080/solr/select?q=(*:*)^0%20%20_val_:"hsin(45.67890,-123.456789,Latitude,Longitude,10)"&fl=score,Latitude,Longitude&sort=score%20asc

assuming this is not a quirk in 1.5, is there some way to convert the hsin
value to distance?

thx
-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26504265.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how is score computed with hsin functionquery?

Posted by gdeconto <ge...@topproducer.com>.
Thanks Lance, I appreciate your response.  

I know what a DIH is and have already written custom transformers.  I just
misunderstood your response to my message (I wasnt aware that we could use
JS to create transformers).

Anyhow, my intent is to change the tool (create a variation of hsin to
support degrees) rather than change the data (which introduces other issues,
such as having to support most systems in degrees and this one system in
radians)

any ideas/advice in that regard?
-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26638720.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how is score computed with hsin functionquery?

Posted by Lance Norskog <go...@gmail.com>.
http://wiki.apache.org/solr/DataImportHandler
http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer

The DIH is a tool inside solr that scripts pulling documents from
different data sources, transforming them and then indexing them.

On Thu, Dec 3, 2009 at 3:10 PM, gdeconto <ge...@topproducer.com> wrote:
>
>
> Lance Norskog-2 wrote:
>>
>> If you use the DataImportHandler you can add your own Javascript code to
>> do the degree->radian conversion.
>>
>
> Thx Lance, but I am not sure what you mean
> --
> View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26634948.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
Lance Norskog
goksron@gmail.com

Re: how is score computed with hsin functionquery?

Posted by gdeconto <ge...@topproducer.com>.

Lance Norskog-2 wrote:
> 
> If you use the DataImportHandler you can add your own Javascript code to
> do the degree->radian conversion.
> 

Thx Lance, but I am not sure what you mean
-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26634948.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how is score computed with hsin functionquery?

Posted by Lance Norskog <go...@gmail.com>.
If you use the DataImportHandler you can add your own Javascript code
to do the degree->radian conversion.



On Wed, Dec 2, 2009 at 8:54 AM, gdeconto <ge...@topproducer.com> wrote:
>
>
> Grant Ingersoll-6 wrote:
>>
>> ...
>> Yep.  Also note that I added deg() and rad() functions, but for the most
>> part is probably better to do the conversion during indexing.
>> ...
>>
>
> as it is not possible for me to convert my data from deg to rad during
> import (since queries are done using degrees), and manually putting in rad()
> stmts into my hsin query seems awkward, I was looking at ways to have solr
> do it for me.
>
> One idea I had was to leverage the existing hsin code (see below).  My
> problem is that HavesineFunction expects ValueSource and I do not see a way
> to convert my radian values back to ValueSource (pls excuse my ignorance on
> this).  Any help/ideas appreciated
>
> public class MyValueSourceParser extends ValueSourceParser {
>    public ValueSource parse(FunctionQParser fp) throws ParseException {
>                ValueSource source = fp.parseValueSource();
>
>                ValueSource x1 = fp.parseValueSource();
>        ValueSource y1 = fp.parseValueSource();
>        ValueSource x2 = fp.parseValueSource();
>        ValueSource y2 = fp.parseValueSource();
>        double radius = fp.parseDouble();
>
>                return HaversineFunction(Math.toRadians(x1), Math.toRadians(y1),
> Math.toRadians(x2), Math.toRadians(y2), radius); // ** how do I convert the
> rad param values to ValueSource **
>        }
> }
> --
> View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26612289.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>



-- 
Lance Norskog
goksron@gmail.com

Re: how is score computed with hsin functionquery?

Posted by gdeconto <ge...@topproducer.com>.

Grant Ingersoll-6 wrote:
> 
> ...
> Yep.  Also note that I added deg() and rad() functions, but for the most
> part is probably better to do the conversion during indexing.
> ...
> 

as it is not possible for me to convert my data from deg to rad during
import (since queries are done using degrees), and manually putting in rad()
stmts into my hsin query seems awkward, I was looking at ways to have solr
do it for me.  

One idea I had was to leverage the existing hsin code (see below).  My
problem is that HavesineFunction expects ValueSource and I do not see a way
to convert my radian values back to ValueSource (pls excuse my ignorance on
this).  Any help/ideas appreciated

public class MyValueSourceParser extends ValueSourceParser {
    public ValueSource parse(FunctionQParser fp) throws ParseException {
		ValueSource source = fp.parseValueSource();

		ValueSource x1 = fp.parseValueSource();
        ValueSource y1 = fp.parseValueSource();
        ValueSource x2 = fp.parseValueSource();
        ValueSource y2 = fp.parseValueSource();
        double radius = fp.parseDouble();

		return HaversineFunction(Math.toRadians(x1), Math.toRadians(y1),
Math.toRadians(x2), Math.toRadians(y2), radius); // ** how do I convert the
rad param values to ValueSource **
	}
}
-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26612289.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how is score computed with hsin functionquery?

Posted by gdeconto <ge...@topproducer.com>.

Grant Ingersoll-6 wrote:
> 
> ...
> Yep.  Also note that I added deg() and rad() functions, but for the most
> part is probably better to do the conversion during indexing.
> ...
> 

Thanks Grant.  I hadnt seen the deg and rad functions.  Conversion would be
difficult since I typically work with degrees.  Once I get a bit more
experienced with the solr code, maybe I can contribute a degree version of
hsin  :-)
-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26515157.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: how is score computed with hsin functionquery?

Posted by Grant Ingersoll <gs...@apache.org>.
On Nov 24, 2009, at 6:22 PM, gdeconto wrote:

> 
> 
> gdeconto wrote:
>> 
>> ...
>> is there some way to convert the hsin value to distance?
>> ...
>> 
> 
> I just noticed that the solr wiki states "Values must be in Radians" and all
> my test values were in degrees.

Yep.  Also note that I added deg() and rad() functions, but for the most part is probably better to do the conversion during indexing.


--------------------------
Grant Ingersoll
http://www.lucidimagination.com/

Search the Lucene ecosystem (Lucene/Solr/Nutch/Mahout/Tika/Droids) using Solr/Lucene:
http://www.lucidimagination.com/search


Re: how is score computed with hsin functionquery?

Posted by gdeconto <ge...@topproducer.com>.

gdeconto wrote:
> 
> ...
> is there some way to convert the hsin value to distance?
> ...
> 

I just noticed that the solr wiki states "Values must be in Radians" and all
my test values were in degrees.

-- 
View this message in context: http://old.nabble.com/how-is-score-computed-with-hsin-functionquery--tp26504265p26505091.html
Sent from the Solr - User mailing list archive at Nabble.com.