Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geo sort #38

Open
nchankov opened this issue Dec 20, 2013 · 1 comment
Open

geo sort #38

nchankov opened this issue Dec 20, 2013 · 1 comment

Comments

@nchankov
Copy link

Hi,

I am wondering how can I use sort by distance? if I set parameter "sort" make it like:

{..., "sort"=>array("name", "id")}

it works ok, but I have a location field which is mapped as "geo_point" but when I add in that array "location" the results disappear, and I guess there is an error underneath (meaning the response from the ES, not your lib)?

Any ideas?

Thank you

@garethwi
Copy link

I had the same problem. This is what I used:

'sort' => array(
                    array(
                        '_geo_distance' => array(
                            'location' => array(
                                'lat' => $this->latitude,
                                'lon' => $this->longitude,
                            ),
                            'order' => 'asc',
                            'unit' => 'km'
                        ),
                    ),
                ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants