SpatialSearch: sorting by distance

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

SpatialSearch: sorting by distance

Pavel Minchenkov
Hi,

I'm trying to sort by distance like this:

sort=dist(2,lat,lon,55.755786,37.617633) asc

In general results are sorted, but some documents are not in right order.
I'm using DistanceUtils.getDistanceMi(...) from lucene spatial to calculate
real distance after reading documents from Solr.

Solr version from trunk.

<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0"
omitNorms="true" positionIncrementGap="0"/>
<field name="lat" type="double" indexed="true" stored="true"/>
<field name="lon" type="double" indexed="true" stored="true"/>

Thanks.

--
Pavel Minchenkov
Reply | Threaded
Open this post in threaded view
|

does this indicate a commit happened for every add?

Petersen, Robert
I'm adding lots of small docs with several threads to solr and the adds
start fast but then slow down.  I didn't do any explicit commits and
autocommit is turned off but the logs show lots of commit activity on
this core and restarting this solr core logged the below.  Where did all
these commits come from, the exact same number as my adds?  I'm
stumped...

Jul 27, 2010 10:07:17 AM org.apache.solr.update.DirectUpdateHandler2
close
INFO: closed
DirectUpdateHandler2{commits=456389,autocommits=0,optimizes=0,rollbacks=
0,expungeDeletes=0,docsPending=0,adds=0,deletesById=0,deletesByQuery=0,e
rrors=0,cumulative_adds=456393,cumulative_deletesById=0,cumulative_delet
esByQuery=0,cumulative_errors=0}
Reply | Threaded
Open this post in threaded view
|

Re: SpatialSearch: sorting by distance

Pavel Minchenkov
In reply to this post by Pavel Minchenkov
Does anybody know if this feature works correctly?
Or I'm doing something wrong?

2010/7/27 Pavel Minchenkov <[hidden email]>

> Hi,
>
> I'm trying to sort by distance like this:
>
> sort=dist(2,lat,lon,55.755786,37.617633) asc
>
> In general results are sorted, but some documents are not in right order.
> I'm using DistanceUtils.getDistanceMi(...) from lucene spatial to calculate
> real distance after reading documents from Solr.
>
> Solr version from trunk.
>
> <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0"
> omitNorms="true" positionIncrementGap="0"/>
> <field name="lat" type="double" indexed="true" stored="true"/>
> <field name="lon" type="double" indexed="true" stored="true"/>
>
> Thanks.
>
> --
> Pavel Minchenkov
>



--
Pavel Minchenkov
Reply | Threaded
Open this post in threaded view
|

Re: does this indicate a commit happened for every add?

Chris Hostetter-3
In reply to this post by Petersen, Robert

: Subject: does this indicate a commit happened for every add?
: In-Reply-To: <[hidden email]>
: References: <[hidden email]>

http://people.apache.org/~hossman/#threadhijack
Thread Hijacking on Mailing Lists

When starting a new discussion on a mailing list, please do not reply to
an existing message, instead start a fresh email.  Even if you change the
subject line of your email, other mail headers still track which thread
you replied to and your question is "hidden" in that thread and gets less
attention.   It makes following discussions in the mailing list archives
particularly difficult.
See Also:  http://en.wikipedia.org/wiki/User:DonDiego/Thread_hijacking



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: SpatialSearch: sorting by distance

Chris Hostetter-3
In reply to this post by Pavel Minchenkov

: sort=dist(2,lat,lon,55.755786,37.617633) asc
:
: In general results are sorted, but some documents are not in right order.
: I'm using DistanceUtils.getDistanceMi(...) from lucene spatial to calculate
: real distance after reading documents from Solr.

according ot the wiki for hte "dist" function...

        "Return the Distance between two Vectors (points)
        in an n-dimensional space."

..and the "2" param in your call means it's going to use the Euclidean
Distance.

where as DistanceUtils.getDistanceMi (allthough undocumented) suggests
that it will return a distance in miles (skimming the code seems to bear
this out ... it just calls getLLMDistance which calls p1.arcDistance( p2,
DistanceUnits.MILES)

I know very little about the spatial package, but i know enough to know
that a vector distance between two arbitrary points in a two dimensional
space is not the same as the distance between two points on *earth* in
miles.

I believe what you want to be using is the "hsin" function

In older versions of SOlr Spatial support, in order for it to work with
"miles on earth" you had to provide the "radius of the earth in miles" as
a param ... i believe that is still possible (and how you cna get the
poutput in other units, like km, or feet), but on the current trunk just
specifying the points should give you the distance in miles by default.



-Hoss