elasticsearch_autocomplete 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,14 @@ module ElasticsearchAutocomplete
43
43
  end
44
44
  end
45
45
 
46
- sort { by options[:order], options[:sort_mode] || 'asc' } if options[:order].present?
46
+ sort do
47
+ if options[:geo_order] && options[:with]
48
+ lat = options[:with].delete('lat').presence
49
+ lon = options[:with].delete('lon').presence
50
+ by('_geo_distance', {'lat_lon' => [lat, lon].join(','), 'order' => 'asc', 'unit' => 'km'}) if lat && lon
51
+ end
52
+ by(options[:order], options[:sort_mode] || 'asc') if options[:order].present?
53
+ end
47
54
 
48
55
  filter(:and, :filters => options[:with].map { |k, v| {:terms => {k => ElasticsearchAutocomplete.val_to_array(v)}} }) if options[:with].present?
49
56
  if options[:without].present?
@@ -67,10 +74,6 @@ module ElasticsearchAutocomplete
67
74
  end
68
75
  end
69
76
 
70
- def for_input_token(r, attr='name_ru')
71
- {:name => r[attr], :id => r.id}
72
- end
73
-
74
77
  def ac_mode_config
75
78
  ElasticsearchAutocomplete::MODES[ac_opts[:mode]]
76
79
  end
@@ -1,3 +1,3 @@
1
1
  module ElasticsearchAutocomplete
2
- VERSION = '0.0.4'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: elasticsearch_autocomplete
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.4
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alex Leschenko
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-14 00:00:00.000000000 Z
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  version_requirements: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: 1402164139427117718
117
+ hash: 1737804148958330559
118
118
  none: false
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: 1402164139427117718
126
+ hash: 1737804148958330559
127
127
  none: false
128
128
  requirements: []
129
129
  rubyforge_project: