Created
May 16, 2016 23:28
-
-
Save leandronsp/428b93edd5f6af14ddaf0dd602fc1e9f to your computer and use it in GitHub Desktop.
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
class CityDocument < ActiveRecord::Base | |
include PgSearch | |
self.table_name = 'city_document_view' | |
self.primary_key = 'city_id' | |
pg_search_scope :_not_so_expensive_search_with_coords, (lambda do |term, lat, lon| | |
{ | |
query: term, | |
## | |
# not using :associated against anymore | |
## | |
against: { | |
city_name: 'A', | |
aliases: 'B', | |
region_name: 'C', | |
country_name: 'D' | |
}, | |
ignoring: :accents, | |
ranked_by: self.complext_script(lat, lon), | |
order_with_rank: 'pg_search_rank DESC' | |
} | |
end) | |
CityDocument._not_so_expensive_search_with_coords('london', 34.54426, -91.96903) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment