This repository has been archived by the owner on Aug 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Native latlon queries with the geo: {...} directive #42
Open
david-l-young
wants to merge
41
commits into
itstommymorgan:master
Choose a base branch
from
david-l-young:native-latlon
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
This adds indexing support for the 2013-01-01 version of the api
adding in batch support and support for compound queries in 2013-01-01 a...
adding in support for sorting and fixing return field support
fixing a bug with indexing
adding in batch delete index functionality
…n to allow for native location searching/sorting
Personally I would love to see this implemented. Even though I don't currently use geo search, Other Issues 1-4 would be great to have fixed. |
… asari indexing callbacks when Asari::ActiveRecord is included
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Friends,
This is not an official pull request. I just wanted to let you know what I have done that support our requirements at Pivotdesk. You can browse the code changes on the 'native-latlon' branch (based on your 1.0 branch). If it looks like something you want to fold back into your project, I will update the documentation and test suite.
I have written extensive tests for our own project that makes use of this forked version, so I am confident that it works. Here is an overview of the changes...
Largely we wanted native 2013-01-01 support for geographic queries. I have implemented this as a new search keyword (geo:) that appears at the same level as that for boolean queries (filter:).
This new keyword supports sorting results relative to a geographic location, or filtering results that are outside of a radius from a geographic location.
The long form looks like this...
-- find documents that mention "donuts" within 5 miles of geographic center of Boulder, CO (assuming documents have a latlon field named 'location')
.search( "donuts", filter: ..., geo: {field: location, latitude: 40.018248, longitude: -105.278163, radius: 5, units: :miles})
The short form allows you to fold the lat/lon in as a value for a geographic field like this...
.search( "donuts", geo: {location: [40.018248, -105.278163], radius: 5, units: :miles)
Other available units for the radius are :kilometers (the default), :meters, or :degrees.
If you just want to sort results by their distance from the location, and not filter anything, it would look like this...
.search( "donuts", geo: {field: location, latitude: 40.018248, longitude: -105.278163, sort: true})
If you don't specify a radius, sorting by distance is the default, so a short form of the above could look like this...
.search( "donuts", geo: {location: [40.018248, -105.278163]})
You can also specify a radius and ask for sort: true, will do both (filter by a radius and sort by the distance from the center).
As I went along, I also fixed some other issues in the filter: syntax...
[1] When filter: was present, the text matching query was being ignored.
[2] Instead of defaulting missing terms to '', leave them out so that the DEFAULT_VALUE on the AWS declarations will kick in.
[3] Implemented 2013-01-01 syntax for more filter terms including open ended ranges and date ranges. You can see this code in the normalize_* functions in the asari.rb class.
[4] Providing an array of values in a filter (filter: {name: ['chocolate cake', 'strawberry frosted']}) generates a query for an OR of the values.
Anyway, let me know if you are interested in an official Pull Request for this work and I will find time to better package it up for you.
Best Regards,
David L Young
CTO at Pivotdesk
david.young@pivotdesk.com
303.916.6942
@PivotdeskCTO