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 stefanocorsi <st...@gmail.com> on 2013/01/21 09:45:43 UTC
Distance Range query
Hello,
I have an index containing items with a range of distance in which I would
like these items to be found when searched. Furthermore, in the same index,
I have the position of the item. For example.
Item A - 46.23211131, 10.3213213131 - 30km
Item B - 45.23211131, 9.3213213131 - 50km
...
Item N - 46.32132132, 10.213211321 - 100Km
I would like to be able to make the following query:
given a certain point X (let's say 46.323231223, 10.32132132131) I would
like to find all the items that are in the range of that point, according to
the item's range: i.e. if an item has a 30Km range, it should find itself in
30Km range from point X, if an item has a 100Km range, it should find itself
in a 100Km range from point X, and so on...
I hope I have explained it in a decent way...
Is there a way to do it? With solr 3? With solr 4?
Thank you for your help...
Stefano
--
View this message in context: http://lucene.472066.n3.nabble.com/Distance-Range-query-tp4034977.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Distance Range query
Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
I'm glad to be of help.
This is all possible using Solr 4 without programatic customization. As
always remember the docs:
http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4#Indexing That
has an example of index a circle. Not much to it.
The only aspect of the SpatialRecursivePrefixTree field that I don't
consider ready for production is retrieving distances, i.e. for sorting or
relevancy or direct retrieval in results. See:
https://issues.apache.org/jira/browse/LUCENE-4698 If you need it but don't
have a lot of data or realtime-search requirements then it's probably fine.
By "legacy tutorial"; what do you refer to?
~ David
stefanocorsi wrote
> Thank you very much David,
>
> your answer is really full of interesting inspiration. To be honest, many
> of the spatial concepts you were writing about are unknown or obscure to
> me, I was only aware of the !geofilt filter with a "distance" parameter,
> but I wasn't aware, for example, that I could index "circles". Do you need
> programmatic structures or can this be configured in
> schema.xml/solrconfig.xml?
>
> Is it all confined to Solr 4? Is it actually stable for production?
>
> Anyway I'll try to find some good tutorial on the general concepts of
> spatial search with solr, the legacy tutorial is actually very poor.
>
> Thank you again!
>
> S.
-----
Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Distance-Range-query-tp4034977p4035422.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Distance Range query
Posted by stefanocorsi <st...@gmail.com>.
Thank you very much David,
your answer is really full of interesting inspiration. To be honest, many of
the spatial concepts you were writing about are unknown or obscure to me, I
was only aware of the !geofilt filter with a "distance" parameter, but I
wasn't aware, for example, that I could index "circles". Do you need
programmatic structures or can this be configured in
schema.xml/solrconfig.xml?
Is it all confined to Solr 4? Is it actually stable for production?
Anyway I'll try to find some good tutorial on the general concepts of
spatial search with solr, the legacy tutorial is actually very poor.
Thank you again!
S.
--
View this message in context: http://lucene.472066.n3.nabble.com/Distance-Range-query-tp4034977p4035388.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: Distance Range query
Posted by "David Smiley (@MITRE.org)" <DS...@mitre.org>.
Hi Stefano.
I answered someone's question on stackoverflow which is basically the same
question you have:
http://stackoverflow.com/questions/13723891/lucene-4-0-spatial-calculate-max-distance-dynamically-using-indexed-documets/13764793#13764793
Essentially, you should index circles and then search by your query point.
That technique requires Solr 4. I recommend the very latest 4.1 about to be
released for indexing non-point shapes as there are some rare bugs in 4.0.
I think you could also do it with Solr 3 spatial with something like:
{!frange l=0 u=99999}sub(distField,geodist(sfield,lat,lon)). However this
is internally a brute-force algorithm vs. Solr 4 indexing shapes which uses
an index (fast!).
~ David
stefanocorsi wrote
> Hello,
>
> I have an index containing items with a range of distance in which I would
> like these items to be found when searched. Furthermore, in the same
> index, I have the position of the item. For example.
>
> Item A - 46.23211131, 10.3213213131 - 30km
> Item B - 45.23211131, 9.3213213131 - 50km
> ...
> Item N - 46.32132132, 10.213211321 - 100Km
>
> I would like to be able to make the following query:
>
> given a certain point X (let's say 46.323231223, 10.32132132131) I would
> like to find all the items that are in the range of that point, according
> to the item's range: i.e. if an item has a 30Km range, it should find
> itself in 30Km range from point X, if an item has a 100Km range, it should
> find itself in a 100Km range from point X, and so on...
>
> I hope I have explained it in a decent way...
>
> Is there a way to do it? With solr 3? With solr 4?
>
> Thank you for your help...
>
> Stefano
-----
Author: http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
--
View this message in context: http://lucene.472066.n3.nabble.com/Distance-Range-query-tp4034977p4035083.html
Sent from the Solr - User mailing list archive at Nabble.com.