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 Spadez <ja...@hotmail.com> on 2012/05/03 16:01:18 UTC

Searching by location – What do I send to Solr?

Hi,

I'm finding it a bit hard to get my head around this. Say I am putting items
on a map. This is how I am thinking it would work:

A user submits an "item" and specifies the location as "London"
On submission, I run a process to convert "London" to a Long/Lat which is
stored in the database

However, when someone then goes onto my site and searches for the postcode
"SE1 2EL", which is in London, how does Solr know the long / lat of this?

Do I have to query Solr by using Long / Lat, in which case, when a user
submits a request for "SE1 2EL" I have to convert this to Long / Lat first
and then send this query to Solr?

I hope I have explained myself well, I would really like to know how others
have solved this.

James


--
View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Searching by location – What do I send to Solr?

Posted by Lance Norskog <go...@gmail.com>.
You could just download postalcodes every day. To be nice, you could
pull the HEAD of each file and check if it is new.

This is just a set of tables, which you denormalize and add to your
other fields.

There are other sources of polygonal shape data, but there is no
official Solr toolkit for querying inside the irregular polygon.

On Thu, May 3, 2012 at 6:19 PM, Erick Erickson <er...@gmail.com> wrote:
> The fact that they're python and java is largely beside the point I think.
> Solr just sees a URL, the fact that your Python app gets in there
> first and "does stuff" with the query wouldn't affect Solr at all.
>
> Also, I tend to like keeping Solr fairly lean so any work I can offload to
> the application I usually do.
>
> YMMV
>
> Best
> Erick
>
> On Thu, May 3, 2012 at 6:43 PM, Spadez <ja...@hotmail.com> wrote:
>> I discounted geonames to start with but it actually looks pretty good. I may
>> be stretching the limit of my question here, but say I did go with geonames,
>> if I go back to my model and add a bit:
>>
>> Search for "London"----->Convert "London to Long/Lat"----->Send Query to
>> Solr>----->Return Query>
>>
>> Since my main website is coded in Python, but Solr works in Java, if I was
>> to create or use an existing script to allow me to convert "London" to
>> Long/Lat, would it make more sense for this operation to be done in Python
>> or Java?
>>
>> In Python it would integrate better with my website, but in Java it would
>> integrate better with Solr. Also would one language be more suitable or
>> faster for this kind of operation?
>>
>> Again, I might be pushing the boundaries of what I can ask on here, but if
>> anyone can chime in with their opinion I would really appreciate it.
>>
>> ~ James
>>
>> --
>> View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960666.html
>> Sent from the Solr - User mailing list archive at Nabble.com.



-- 
Lance Norskog
goksron@gmail.com

Re: Searching by location – What do I send to Solr?

Posted by Erick Erickson <er...@gmail.com>.
The fact that they're python and java is largely beside the point I think.
Solr just sees a URL, the fact that your Python app gets in there
first and "does stuff" with the query wouldn't affect Solr at all.

Also, I tend to like keeping Solr fairly lean so any work I can offload to
the application I usually do.

YMMV

Best
Erick

On Thu, May 3, 2012 at 6:43 PM, Spadez <ja...@hotmail.com> wrote:
> I discounted geonames to start with but it actually looks pretty good. I may
> be stretching the limit of my question here, but say I did go with geonames,
> if I go back to my model and add a bit:
>
> Search for "London"----->Convert "London to Long/Lat"----->Send Query to
> Solr>----->Return Query>
>
> Since my main website is coded in Python, but Solr works in Java, if I was
> to create or use an existing script to allow me to convert "London" to
> Long/Lat, would it make more sense for this operation to be done in Python
> or Java?
>
> In Python it would integrate better with my website, but in Java it would
> integrate better with Solr. Also would one language be more suitable or
> faster for this kind of operation?
>
> Again, I might be pushing the boundaries of what I can ask on here, but if
> anyone can chime in with their opinion I would really appreciate it.
>
> ~ James
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960666.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Searching by location – What do I send to Solr?

Posted by Spadez <ja...@hotmail.com>.
I discounted geonames to start with but it actually looks pretty good. I may
be stretching the limit of my question here, but say I did go with geonames,
if I go back to my model and add a bit:

Search for "London"----->Convert "London to Long/Lat"----->Send Query to
Solr>----->Return Query>

Since my main website is coded in Python, but Solr works in Java, if I was
to create or use an existing script to allow me to convert "London" to
Long/Lat, would it make more sense for this operation to be done in Python
or Java?

In Python it would integrate better with my website, but in Java it would
integrate better with Solr. Also would one language be more suitable or
faster for this kind of operation?

Again, I might be pushing the boundaries of what I can ask on here, but if
anyone can chime in with their opinion I would really appreciate it.

~ James

--
View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960666.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Searching by location – What do I send to Solr?

Posted by Jack Krupansky <ja...@basetechnology.com>.
I have heard that GeoNames is a great source for name/location information.

They even have UK postal codes:
http://www.geonames.org/postal-codes/postal-codes-uk.html

-- Jack Krupansky

-----Original Message----- 
From: Michael Della Bitta
Sent: Thursday, May 03, 2012 3:32 PM
To: solr-user@lucene.apache.org
Subject: Re: Searching by location – What do I send to Solr?

Have you tried www.geonames.org ?

- Michael


On Thu, 2012-05-03 at 12:20 -0700, Spadez wrote:
> Hi,
>
> This is quite a challenge. I know there are situations when you can get by
> with google maps api or similar, but they limit the number of requests and 
> I
> need more than that, unfortunatly for the full service they charge a
> fortune!
>
> So, going back to my question, does anyone have any ideas or suggestions 
> of
> a good solution?
>
> Search for "London"----->*Convert "London to Long/Lat"*----->Send Query to
> Solr>----->Return Query>
>
> --
> View this message in context: 
> http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960231.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: Searching by location – What do I send to Solr?

Posted by Michael Della Bitta <mi...@appinions.com>.
Have you tried www.geonames.org ?

- Michael


On Thu, 2012-05-03 at 12:20 -0700, Spadez wrote:
> Hi,
> 
> This is quite a challenge. I know there are situations when you can get by
> with google maps api or similar, but they limit the number of requests and I
> need more than that, unfortunatly for the full service they charge a
> fortune!
> 
> So, going back to my question, does anyone have any ideas or suggestions of
> a good solution?
> 
> Search for "London"----->*Convert "London to Long/Lat"*----->Send Query to
> Solr>----->Return Query>
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960231.html
> Sent from the Solr - User mailing list archive at Nabble.com.



RE: Searching by location - What do I send to Solr?

Posted by "Welty, Richard" <rw...@ltionline.com>.
this is called geocoding and is properly a subject for GIS types.
it can be non trivial and the data you need to set it up may not be cheap.
i can't address the UK application, but i am somewhat familiar with the US
problem space, and in the US 5 digit postal ("zip") codes don't map to
discreet locations, they map to bundles of postal delivery routes.

you need, i think, to research how UK postal codes actually work and what
data sources are available so that you can frame your problem appropriately.

richard

-----Original Message-----
From: Spadez [mailto:james_willson@hotmail.com]
Sent: Thu 5/3/2012 3:20 PM
To: solr-user@lucene.apache.org
Subject: Re: Searching by location - What do I send to Solr?
 
Hi,

This is quite a challenge. I know there are situations when you can get by
with google maps api or similar, but they limit the number of requests and I
need more than that, unfortunatly for the full service they charge a
fortune!

So, going back to my question, does anyone have any ideas or suggestions of
a good solution?

Search for "London"----->*Convert "London to Long/Lat"*----->Send Query to
Solr>----->Return Query>

--
View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960231.html
Sent from the Solr - User mailing list archive at Nabble.com.



Re: Searching by location – What do I send to Solr?

Posted by Spadez <ja...@hotmail.com>.
Hi,

This is quite a challenge. I know there are situations when you can get by
with google maps api or similar, but they limit the number of requests and I
need more than that, unfortunatly for the full service they charge a
fortune!

So, going back to my question, does anyone have any ideas or suggestions of
a good solution?

Search for "London"----->*Convert "London to Long/Lat"*----->Send Query to
Solr>----->Return Query>

--
View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296p3960231.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Searching by location – What do I send to Solr?

Posted by Erick Erickson <er...@gmail.com>.
You're on the right track. Solr knows nothing about converting
post codes to lat/lon, you have to do that outside the request
and submit a standard distance query.

Of course this is a bit "interesting". I assume the post codes aren't
perfectly circular (or rectangular for that matter) so you'll get some data
don't expect. Is this OK?

Best
Erick

On Thu, May 3, 2012 at 10:01 AM, Spadez <ja...@hotmail.com> wrote:
> Hi,
>
> I'm finding it a bit hard to get my head around this. Say I am putting items
> on a map. This is how I am thinking it would work:
>
> A user submits an "item" and specifies the location as "London"
> On submission, I run a process to convert "London" to a Long/Lat which is
> stored in the database
>
> However, when someone then goes onto my site and searches for the postcode
> "SE1 2EL", which is in London, how does Solr know the long / lat of this?
>
> Do I have to query Solr by using Long / Lat, in which case, when a user
> submits a request for "SE1 2EL" I have to convert this to Long / Lat first
> and then send this query to Solr?
>
> I hope I have explained myself well, I would really like to know how others
> have solved this.
>
> James
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Searching-by-location-What-do-I-send-to-Solr-tp3959296.html
> Sent from the Solr - User mailing list archive at Nabble.com.