django-haystack / django-haystack/django-haystack
Use spatial search as sub-query?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 1.3k
- Avg merge
- 3h 18m
- Merged PRs (30d)
- 3
Description
- Operating system version: ubuntu 14.04 LTS / linux 3.11.0-15
- Search engine version: solr-4.10.2
- Python version: python 2.7.5+
- Django version: django 1.6.5
- Haystack version: django-haystack==2.4.1
I've read in the Solr documentation the following query and I wonder if I could build it in Haystack.
Use as a Sub-Query to Expand Search Results
Here we will query for results in Jacksonville, Florida, or within 50 kilometers of 45.15,-93.85 (near Buffalo, Minnesota):
&q=*:*&fq=(state:"FL" AND city:"Jacksonville") OR {!geofilt}&sfield=store&pt=45.15,-93.85&d=50&sort=geodist()+asc
I've tried doing this similar query but seems like it's not the way to do that
>>> point = Point(place.lng, place.lat)
>>> distance = D(km=1)
>>> SearchQuerySet().filter(park="Gramercy Park").dwithin('location', point, distance)
...hits -> http://127.0.0.1:8983/solr/select/?fq=django_ct:(parks.park)&fq={!geofilt pt=40.7502,-73.9969 sfield=location d=1.0}&rows=20&q=(park:"Gramercy Park")&start=0&wt=json&fl=* score
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the SearchQuerySet().filter(...).dwithin() example and compare its generated Solr query with the linked spatial-search sub-query syntax. Determine the intended Haystack API and define support for combining the city/state filter with the geographic filter, including a test that verifies the resulting query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- search
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100