Question

I'm currently using django haystack with xapian. I couldn't find any documentation on how to perform geospatial queries on xapian. But there seems to be some momentum on Solr. So i'm currently experimenting with that.

I couldn't get spatialSolr to work properly on local, but for now working with spatial-solr-light, which seems to work fine. It accepts queries like

http://127.0.0.1:8080/solr/select/?q=blahblah&spatial={!radius=1.0%20sort=true}lat:10.0,lng:-10.0

Can anyony point me to a patch for haystack that allows me to pass custom queries like that. I could use raw_search(), but i can't chain the resuts. In any case i would like to find a cleaner way to do something like sqs.spatial(....)

There are some patches from other people mentioned on the google group(links below), but most of them are unreachable.

References:

Was it helpful?

Solution 2

Here's a fork of django haystack that adds in support for :

https://github.com/sidmitra/django-haystack-spatialsolrplugin

And corresponding notes are here: https://github.com/sidmitra/django-haystack-spatialsolrplugin/wiki/_pages

OTHER TIPS

If you're not tied to Xapian, look at Django, Sphinx and search by distance. I had a similar problem when I ran across this question and this seems to solve it. Thanks to django-sphinx, it's about as easy to set up as Haystack. Sphinx also seems to offer more flexibility.

Sidmitra, I made port of your solution using haystack 1.2.X and solr 3.4. With some limitations to be frank - no support for schema generation at the moment, only LatLong geo type supported, sorting by distance is not perfect (but works)

https://github.com/frutik/django-haystack/tree/1.2.X

I agree with https://github.com/sidmitra/django-haystack-spatialsolrplugin .

It seems to be out-of-date, but I could beat it into shape with some work. Issues I had:

  • Hard to find the java SSP and when I found it it was the wrong version. http://www.dutchworks.nl/en/home/download.html was the link that worked for me.

  • The classpaths in the example xml files I found on the net were all wrong; I had to remove .solrext. from all of them.

  • The plugin was very picky about which directory it lived in; it couldn't talk to anything else until it was happily in solr/lib

  • solr_backend.py required the following patch (around line 505):

    if self.spatial_query:
        final_query = '{{!spatial circles={lat},{long},{radius} }}{0}'.format(final_query,**self.spatial_query)
    
  • I had further issues with making the solrconfig.xml so that GeoDistanceComponent never loaded before the query had a valid rsp.

In other words, you can certainly make it work, but you have to be able to deal with a number of error messages in both python and java before you get there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top