forked from django-haystack/django-haystack
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly handle distance information returned in ElasticSearch results.
- Loading branch information
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d5cc42f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this is needed, can you elaborate?
d5cc42f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jezdez
Er, sorry, I thought I had created a separate pull for this commit. Basically, the distance information returned by ElasticSearch isn't processed by when building search result objects. This commit implements it in a similar fashion as in the Solr backend (L379). The canonical example of this usage is shown in the docs here.
There are a few things going on in this commit of note:
geo_sort
variable is set toTrue
(L302).distance()
call is passed to the_process_results
method, along withgeo_sort
(L499)_point_of_origin
additional field is set to the distance point so the Haystack can calculate the distance information with GeoPy. This is needed because ElasticSearch only returns distance information when sorting by distance. (L592)Sorry about the confusion, let me know if there's anything else I can help with.