django-haystack / django-haystack/django-haystack

Use spatial search as sub-query?

Open
#1,446 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.