picky 3.6.16 → 4.0.0pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/lib/picky/application.rb +1 -1
  2. data/lib/picky/backends/backend.rb +2 -0
  3. data/lib/picky/backends/memory.rb +14 -7
  4. data/lib/picky/backends/{memory → prepared}/text.rb +10 -4
  5. data/lib/picky/backends/redis/directly_manipulable.rb +3 -5
  6. data/lib/picky/backends/redis/list.rb +5 -1
  7. data/lib/picky/backends/sqlite/basic.rb +4 -2
  8. data/lib/picky/bundle.rb +6 -7
  9. data/lib/picky/bundle_indexed.rb +2 -2
  10. data/lib/picky/bundle_realtime.rb +8 -7
  11. data/lib/picky/categories.rb +0 -1
  12. data/lib/picky/categories_indexing.rb +14 -0
  13. data/lib/picky/category.rb +3 -5
  14. data/lib/picky/category_indexed.rb +2 -5
  15. data/lib/picky/category_indexing.rb +28 -16
  16. data/lib/picky/constants.rb +3 -1
  17. data/lib/picky/frontend_adapters/rack.rb +2 -2
  18. data/lib/picky/generators/similarity/phonetic.rb +6 -14
  19. data/lib/picky/generators/strategy.rb +1 -1
  20. data/lib/picky/generators/weights/runtime.rb +2 -2
  21. data/lib/picky/helpers/indexing.rb +20 -0
  22. data/lib/picky/index.rb +7 -10
  23. data/lib/picky/index_indexed.rb +1 -8
  24. data/lib/picky/index_indexing.rb +44 -42
  25. data/lib/picky/indexers/base.rb +5 -6
  26. data/lib/picky/indexers/parallel.rb +35 -32
  27. data/lib/picky/indexers/serial.rb +38 -15
  28. data/lib/picky/indexes_indexed.rb +0 -7
  29. data/lib/picky/indexes_indexing.rb +16 -19
  30. data/lib/picky/loader.rb +6 -4
  31. data/lib/picky/query/allocation.rb +7 -2
  32. data/lib/picky/query/combination.rb +1 -1
  33. data/lib/picky/query/indexes.rb +1 -1
  34. data/lib/picky/query/indexes_check.rb +12 -14
  35. data/lib/picky/query/token.rb +33 -15
  36. data/lib/picky/results/exact_first.rb +53 -0
  37. data/lib/picky/scheduler.rb +43 -0
  38. data/lib/picky/search.rb +0 -2
  39. data/lib/picky/sources/csv.rb +2 -3
  40. data/lib/picky/sources/db.rb +4 -3
  41. data/lib/picky/sources/mongo.rb +1 -1
  42. data/lib/picky/tokenizer.rb +0 -4
  43. data/lib/picky/wrappers/bundle/location.rb +1 -1
  44. data/lib/picky.rb +2 -2
  45. data/lib/tasks/index.rake +13 -14
  46. data/spec/functional/backends/file_spec.rb +2 -4
  47. data/spec/functional/backends/memory_spec.rb +2 -2
  48. data/spec/functional/backends/redis_spec.rb +1 -1
  49. data/spec/functional/exact_first_spec.rb +24 -4
  50. data/spec/functional/realtime_spec.rb +7 -3
  51. data/spec/lib/application_spec.rb +30 -30
  52. data/spec/lib/backends/backend_spec.rb +25 -27
  53. data/spec/lib/backends/{memory → prepared}/text_spec.rb +1 -1
  54. data/spec/lib/category_indexing_spec.rb +1 -1
  55. data/spec/lib/extensions/symbol_spec.rb +1 -1
  56. data/spec/lib/generators/similarity/phonetic_spec.rb +46 -0
  57. data/spec/lib/index_indexed_spec.rb +5 -5
  58. data/spec/lib/index_indexing_spec.rb +13 -12
  59. data/spec/lib/index_spec.rb +8 -8
  60. data/spec/lib/indexers/base_spec.rb +5 -6
  61. data/spec/lib/indexers/parallel_spec.rb +10 -10
  62. data/spec/lib/indexes_indexed_spec.rb +1 -7
  63. data/spec/lib/indexes_indexing_spec.rb +10 -5
  64. data/spec/lib/query/indexes_check_spec.rb +44 -15
  65. data/spec/lib/query/indexes_spec.rb +11 -11
  66. data/spec/lib/query/token_spec.rb +10 -0
  67. data/spec/lib/{indexed/wrappers → results}/exact_first_spec.rb +18 -21
  68. data/spec/lib/scheduler_spec.rb +92 -0
  69. metadata +45 -34
  70. data/lib/picky/cores.rb +0 -127
  71. data/lib/picky/tokenizers/location.rb +0 -53
  72. data/lib/picky/wrappers/category/exact_first.rb +0 -94
  73. data/spec/lib/cores_spec.rb +0 -185
@@ -200,7 +200,7 @@ module Picky
200
200
  Loader.load_user 'app' # Sinatra appfile.
201
201
  Loader.load_user 'app/application' # Standard Picky appfile.
202
202
  finalize_apps
203
- exclaim "Application #{apps.map(&:name).join(', ')} loaded."
203
+ exclaim "Loaded Picky application(s) with environment '#{PICKY_ENVIRONMENT}' in #{PICKY_ROOT} on Ruby #{RUBY_VERSION}."
204
204
  end
205
205
 
206
206
  # Finalize the subclass as soon as it
@@ -2,6 +2,8 @@ module Picky
2
2
 
3
3
  module Backends
4
4
 
5
+ #
6
+ #
5
7
  class Backend
6
8
 
7
9
  attr_reader :inverted,
@@ -4,35 +4,40 @@ module Picky
4
4
 
5
5
  class Memory < Backend
6
6
 
7
- # Returns an object that on #initial, #load returns an object that responds to:
7
+ # Returns an object that on #initial, #load returns
8
+ # an object that responds to:
8
9
  # [:token] # => [id, id, id, id, id] (an array of ids)
9
10
  #
10
11
  def create_inverted bundle
11
12
  extract_lambda_or(inverted, bundle) ||
12
13
  JSON.new(bundle.index_path(:inverted))
13
14
  end
14
- # Returns an object that on #initial, #load returns an object that responds to:
15
+ # Returns an object that on #initial, #load returns
16
+ # an object that responds to:
15
17
  # [:token] # => 1.23 (a weight)
16
18
  #
17
19
  def create_weights bundle
18
20
  extract_lambda_or(weights, bundle) ||
19
21
  JSON.new(bundle.index_path(:weights))
20
22
  end
21
- # Returns an object that on #initial, #load returns an object that responds to:
23
+ # Returns an object that on #initial, #load returns
24
+ # an object that responds to:
22
25
  # [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
23
26
  #
24
27
  def create_similarity bundle
25
28
  extract_lambda_or(similarity, bundle) ||
26
29
  Marshal.new(bundle.index_path(:similarity))
27
30
  end
28
- # Returns an object that on #initial, #load returns an object that responds to:
31
+ # Returns an object that on #initial, #load returns
32
+ # an object that responds to:
29
33
  # [:key] # => value (a value for this config key)
30
34
  #
31
35
  def create_configuration bundle
32
36
  extract_lambda_or(configuration, bundle) ||
33
37
  JSON.new(bundle.index_path(:configuration))
34
38
  end
35
- # Returns an object that on #initial, #load returns an object that responds to:
39
+ # Returns an object that on #initial, #load returns
40
+ # an object that responds to:
36
41
  # [id] # => [:sym1, :sym2]
37
42
  #
38
43
  def create_realtime bundle
@@ -50,8 +55,10 @@ module Picky
50
55
  # Note: Uses a C-optimized intersection routine (in performant.c)
51
56
  # for speed and memory efficiency.
52
57
  #
53
- # Note: In the memory based version we ignore the amount and offset hints.
54
- # We cannot use the information to speed up the algorithm, unfortunately.
58
+ # Note: In the memory based version we ignore the amount and
59
+ # offset hints.
60
+ # We cannot use the information to speed up the algorithm,
61
+ # unfortunately.
55
62
  #
56
63
  def ids combinations, _, _
57
64
  # Get the ids for each combination.
@@ -2,13 +2,19 @@ module Picky
2
2
 
3
3
  module Backends
4
4
 
5
- class Memory
5
+ class Prepared
6
6
 
7
7
  # Index data dumped in the text format.
8
8
  #
9
- # TODO Should this really be Memory::Text?
10
- #
11
- class Text < Basic
9
+ class Text
10
+
11
+ include Helpers::File
12
+
13
+ attr_reader :cache_path
14
+
15
+ def initialize cache_path, options = {}
16
+ @cache_path = "#{cache_path}.prepared.#{extension}"
17
+ end
12
18
 
13
19
  # Uses the extension "txt".
14
20
  #
@@ -14,7 +14,7 @@ module Picky
14
14
  list.key = key
15
15
  end
16
16
 
17
- # TODO Current implementation is very brittle.
17
+ # THINK Current implementation is very brittle.
18
18
  #
19
19
  @@append_index = 0
20
20
  def << value
@@ -23,7 +23,7 @@ module Picky
23
23
  backend[key]
24
24
  end
25
25
 
26
- # TODO Current implementation is very brittle.
26
+ # THINK Current implementation is very brittle.
27
27
  #
28
28
  @@unshift_index = 0
29
29
  def unshift value
@@ -34,9 +34,7 @@ module Picky
34
34
 
35
35
  def delete value
36
36
  result = super value
37
- if result
38
- backend.client.zrem "#{backend.namespace}:#{key}", value # TODO if super(value) ?
39
- end
37
+ backend.client.zrem "#{backend.namespace}:#{key}", value if result
40
38
  result
41
39
  end
42
40
  end
@@ -54,6 +54,8 @@ module Picky
54
54
 
55
55
  # Set a single list.
56
56
  #
57
+ # TODO We should optimize this by only adding. Maybe only add the difference?
58
+ #
57
59
  def []= key, values
58
60
  redis_key = "#{namespace}:#{key}"
59
61
  i = 0
@@ -62,7 +64,9 @@ module Picky
62
64
  client.zadd redis_key, i, value
63
65
  end
64
66
 
65
- self[key] # TODO Performance?
67
+ # We need to return the whole list.
68
+ #
69
+ self[key]
66
70
  end
67
71
 
68
72
  end
@@ -67,9 +67,11 @@ module Picky
67
67
  self
68
68
  end
69
69
 
70
+ # Drops the table and creates it anew.
71
+ #
72
+ # THINK Could this be replaced by a truncate (DELETE FROM) statement?
73
+ #
70
74
  def truncate_db
71
- # TODO Could this be replaced by a truncate statement?
72
- #
73
75
  drop_table
74
76
  create_table
75
77
  end
data/lib/picky/bundle.rb CHANGED
@@ -47,15 +47,13 @@ module Picky
47
47
  @name = name
48
48
  @category = category
49
49
 
50
- # TODO Tidy up a bit.
51
- #
52
- @key_format = options.delete :key_format
53
- @backend = options.delete :backend
54
-
55
50
  @weights_strategy = weights_strategy
56
51
  @partial_strategy = partial_strategy
57
52
  @similarity_strategy = similarity_strategy
58
53
 
54
+ @key_format = options.delete :key_format
55
+ @backend = options.delete :backend
56
+
59
57
  reset_backend
60
58
  end
61
59
  def identifier
@@ -106,7 +104,7 @@ module Picky
106
104
  @inverted = @backend_inverted.empty
107
105
  end
108
106
  def empty_weights
109
- # TODO THINK about this. Perhaps the strategies should implement the backend methods?
107
+ # THINK about this. Perhaps the strategies should implement the backend methods?
110
108
  #
111
109
  @weights = @weights_strategy.saved?? @backend_weights.empty : @weights_strategy
112
110
  end
@@ -126,7 +124,8 @@ module Picky
126
124
  #
127
125
  def similar text
128
126
  code = similarity_strategy.encoded text
129
- similar_codes = code && @similarity[code]
127
+ return [] unless code
128
+ similar_codes = @similarity[code]
130
129
  if similar_codes.blank?
131
130
  [] # Return a simple array.
132
131
  else
@@ -20,8 +20,8 @@ module Picky
20
20
  #
21
21
  # Returns a (potentially empty) array of ids.
22
22
  #
23
- # TODO Empty string ok, or does it need to be from the backend?
24
- # Should the backend always return an empty array? (Probably no)
23
+ # Note: If the backend wants to return a special
24
+ # enumerable, the backend should do so.
25
25
  #
26
26
  def ids sym_or_string
27
27
  @inverted[sym_or_string] || []
@@ -47,8 +47,6 @@ module Picky
47
47
  #
48
48
  str_or_syms << str_or_sym
49
49
 
50
- # TODO Introduce a new method?
51
- #
52
50
  ids = @inverted[str_or_sym] ||= []
53
51
  ids.send where, id
54
52
  end
@@ -68,8 +66,6 @@ module Picky
68
66
 
69
67
  # Add string/symbol to similarity index.
70
68
  #
71
- # TODO Probably where makes no sense here. Should have its own order.
72
- #
73
69
  def add_similarity str_or_sym, where = :unshift
74
70
  if encoded = self.similarity_strategy.encoded(str_or_sym)
75
71
  similars = @similarity[encoded] ||= []
@@ -77,7 +73,11 @@ module Picky
77
73
  # Not completely correct, as others will also be affected, but meh.
78
74
  #
79
75
  similars.delete str_or_sym if similars.include? str_or_sym
80
- similars.send where, str_or_sym
76
+ similars << str_or_sym
77
+
78
+ # Uses the sort order of the strategy.
79
+ #
80
+ self.similarity_strategy.sort similars, str_or_sym
81
81
  end
82
82
  end
83
83
 
@@ -91,9 +91,10 @@ module Picky
91
91
 
92
92
  # Builds the realtime mapping.
93
93
  #
94
- # Note: Experimental feature.
94
+ # Note: Experimental feature. Might be removed in 4.0.
95
95
  #
96
- # TODO Subset of #add. Rewrite.
96
+ # TODO Subset of #add. Rewrite, optimize.
97
+ # THINK Maybe load it and just replace the arrays with the corresponding ones.
97
98
  #
98
99
  def build_realtime
99
100
  clear_realtime
@@ -12,7 +12,6 @@ module Picky
12
12
  each_delegate :cache,
13
13
  :dump,
14
14
  :empty,
15
- :index,
16
15
  :inject,
17
16
  :reindex,
18
17
  :reset_backend,
@@ -2,11 +2,25 @@ module Picky
2
2
 
3
3
  class Categories
4
4
 
5
+ include Helpers::Indexing
6
+
5
7
  each_delegate :cache,
6
8
  :clear,
7
9
  :prepare,
8
10
  :to => :categories
9
11
 
12
+ # First prepares all categories,
13
+ # then caches all categories.
14
+ #
15
+ def index scheduler = Scheduler.new
16
+ timed_indexing scheduler do
17
+ categories.prepare scheduler
18
+ scheduler.finish
19
+
20
+ categories.cache scheduler
21
+ scheduler.finish
22
+ end
23
+ end
10
24
  end
11
25
 
12
26
  end
@@ -55,7 +55,7 @@ module Picky
55
55
  @partial = Bundle.new :partial, self, weights, partial, no_similarity, options
56
56
  end
57
57
 
58
- @prepared = Backends::Memory::Text.new prepared_index_path
58
+ @prepared = Backends::Prepared::Text.new prepared_index_path
59
59
  end
60
60
 
61
61
  # Indexes and loads the category.
@@ -70,7 +70,7 @@ module Picky
70
70
  def dump
71
71
  exact.dump
72
72
  partial.dump
73
- timed_exclaim %Q{"#{identifier}": Generated -> #{index_directory.gsub("#{PICKY_ROOT}/", '')}.}
73
+ timed_exclaim %Q{ "#{identifier}": Dumped -> #{index_directory.gsub("#{PICKY_ROOT}/", '')}/#{name}_*.}
74
74
  end
75
75
 
76
76
  # Returns the backend.
@@ -121,14 +121,12 @@ module Picky
121
121
  # Note: If you don't use it with the block, do not forget to close it.
122
122
  #
123
123
  def prepared_index_file &block
124
- @prepared_index_file ||= Backends::Memory::Text.new prepared_index_path
124
+ @prepared_index_file ||= Backends::Prepared::Text.new prepared_index_path
125
125
  @prepared_index_file.open &block
126
126
  end
127
127
 
128
128
  # The index directory for this category.
129
129
  #
130
- # TODO Push down into files? Yes.
131
- #
132
130
  def index_directory
133
131
  @index_directory ||= "#{PICKY_ROOT}/index/#{PICKY_ENVIRONMENT}/#{@index.name}"
134
132
  end
@@ -7,14 +7,11 @@ module Picky
7
7
  # Loads the index from cache.
8
8
  #
9
9
  def load
10
- timed_exclaim %Q{"#{identifier}": Loading index from cache.}
11
- clear_realtime # TODO What to do?
10
+ timed_exclaim %Q{ "#{identifier}": Loading index from cache.}
11
+ clear_realtime # THINK Should we really explicitly clear the realtime? Or should it just be loaded?
12
12
  exact.load
13
13
  partial.load
14
14
  end
15
- # TODO Remove in 4.0.
16
- #
17
- alias reload load
18
15
 
19
16
  # Gets the weight for this token's text.
20
17
  #
@@ -4,6 +4,8 @@ module Picky
4
4
  #
5
5
  class Category
6
6
 
7
+ include Helpers::Indexing
8
+
7
9
  attr_reader :exact,
8
10
  :partial
9
11
 
@@ -11,18 +13,37 @@ module Picky
11
13
  #
12
14
  # This one should be used by users.
13
15
  #
14
- def index
15
- prepare
16
- cache
16
+ def index scheduler = Scheduler.new
17
+ timed_indexing scheduler do
18
+ prepare scheduler
19
+ scheduler.finish
20
+
21
+ cache scheduler
22
+ scheduler.finish
23
+ end
17
24
  end
18
25
 
19
26
  # Indexes, creates the "prepared_..." file.
20
27
  #
21
- def prepare
28
+ def prepare scheduler = Scheduler.new
22
29
  categories = Categories.new
23
30
  categories << self
24
31
  with_data_snapshot do
25
- indexer.index categories
32
+ scheduler.schedule do
33
+ indexer.prepare categories, scheduler
34
+ nil # TODO Needed so procrastinate is happy. Remove in 4.0.
35
+ end
36
+ end
37
+ end
38
+
39
+ # Generates all caches for this category.
40
+ #
41
+ def cache scheduler = Scheduler.new
42
+ scheduler.schedule do
43
+ empty
44
+ retrieve
45
+ dump
46
+ nil # TODO Needed so procrastinate is happy. Remove in 4.0.
26
47
  end
27
48
  end
28
49
 
@@ -45,15 +66,6 @@ module Picky
45
66
  end
46
67
  end
47
68
 
48
- # Generates all caches for this category.
49
- #
50
- def cache
51
- empty
52
- retrieve
53
- dump
54
- clear_realtime # TODO To call or not to call, that is the question.
55
- end
56
-
57
69
  # Retrieves the prepared index data into the indexes and
58
70
  # generates the necessary derived indexes.
59
71
  #
@@ -109,8 +121,8 @@ module Picky
109
121
 
110
122
  # Clears the caches.
111
123
  #
112
- # TODO Think about the semantics of clear.
113
- # Is a delete even needed or is it clear+dump?
124
+ # THINK about the semantics of clear.
125
+ # Is a delete even needed or is it clear+dump?
114
126
  #
115
127
  def clear
116
128
  exact.clear
@@ -6,4 +6,6 @@
6
6
  ENV['PICKY_ENV'] ||= ENV['RACK_ENV']
7
7
 
8
8
  PICKY_ENVIRONMENT = ENV['PICKY_ENV'] || 'development' unless defined? PICKY_ENVIRONMENT
9
- PICKY_ROOT = Dir.pwd unless defined? PICKY_ROOT
9
+ PICKY_ROOT = Dir.pwd unless defined? PICKY_ROOT
10
+
11
+ EMPTY_STRING = ''.freeze
@@ -90,8 +90,8 @@ module Picky
90
90
  # Note: Rack-mount already handles the 404.
91
91
  #
92
92
  STATUSES = {
93
- 200 => lambda { |_| [200, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, ['']] },
94
- 404 => lambda { |_| [404, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, ['']] }
93
+ 200 => lambda { |_| [200, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, [EMPTY_STRING]] },
94
+ 404 => lambda { |_| [404, { 'Content-Type' => 'text/html', 'Content-Length' => '0' }, [EMPTY_STRING]] }
95
95
  }
96
96
 
97
97
  #
@@ -23,20 +23,12 @@ module Picky
23
23
  @amount = amount
24
24
  end
25
25
 
26
- protected
27
-
28
- # Sorts the index values in place.
29
- #
30
- # TODO Include this again. Sort at the end.
31
- # Or sort when inserting in realtime.
32
- #
33
- def sort hash
34
- hash.each_pair.each do |code, ary|
35
- ary.sort_by_levenshtein! code
36
- ary.slice! amount, ary.size # size is not perfectly correct, but anyway
37
- end
38
- hash
39
- end
26
+ # Sorts the index values in place.
27
+ #
28
+ def sort ary, code
29
+ ary.sort_by_levenshtein! code
30
+ ary.slice! amount, ary.size # THINK size is not perfectly correct, but anyway
31
+ end
40
32
 
41
33
  end
42
34
 
@@ -7,7 +7,7 @@ module Picky
7
7
  # By default, all caches are saved in a
8
8
  # storage (like a file).
9
9
  #
10
- # TODO Move to the backends?
10
+ # TODO Move to the backends? Rename to backend?
11
11
  #
12
12
  def saved?
13
13
  true
@@ -9,8 +9,8 @@ module Picky
9
9
  # does nothing at all.
10
10
  #
11
11
  # To override, implement:
12
- # * weight_for(size) # During indextime. # Probably never used.
13
- # * [] symbol_or_string # During runtime.
12
+ # * [symbol_or_string] # During runtime.
13
+ # * weight_for(size) # During indextime. # Probably never used.
14
14
  #
15
15
  # TODO Find a better name.
16
16
  #
@@ -0,0 +1,20 @@
1
+ module Picky
2
+
3
+ # Helper methods for measuring, benchmarking, logging.
4
+ #
5
+ module Helpers
6
+ module Indexing
7
+
8
+ include Measuring
9
+
10
+ # Returns a duration in seconds.
11
+ #
12
+ def timed_indexing scheduler, &block
13
+ timed_exclaim "Indexing using #{scheduler.fork? ? 'multiple processes' : 'a single process'}."
14
+ timed_exclaim "Indexing finished after #{timed(&block).round}s."
15
+ end
16
+
17
+ end
18
+ end
19
+
20
+ end
data/lib/picky/index.rb CHANGED
@@ -167,7 +167,7 @@ module Picky
167
167
  # * qualifiers: An array of qualifiers with which you can define which category you’d like to search, for example “title:hobbit” will search for hobbit in just title categories. Example: qualifiers: [:t, :titre, :title] (use it for example with multiple languages). Default is the name of the category.
168
168
  # * qualifier: Convenience options if you just need a single qualifier, see above. Example: qualifiers => :title. Default is the name of the category.
169
169
  # * source: Use a different source than the index uses. If you think you need that, there might be a better solution to your problem. Please post to the mailing list first with your application.rb :)
170
- # * from: Take the data from the data category with this name. Example: You have a source Sources::CSV.new(:title, file:'some_file.csv') but you want the category to be called differently. The you use from: define_category(:similar_title, :from => :title).
170
+ # * from: Take the data from the data category with this name. Example: You have a source Sources::CSV.new(:title, file:'some_file.csv') but you want the category to be called differently. The you use from: category(:similar_title, :from => :title).
171
171
  #
172
172
  def category category_name, options = {}
173
173
  new_category = Category.new category_name.intern, self, options
@@ -177,7 +177,6 @@ module Picky
177
177
 
178
178
  new_category
179
179
  end
180
- alias define_category category
181
180
 
182
181
  # Make this category range searchable with a fixed range. If you need other
183
182
  # ranges, define another category with a different range value.
@@ -233,7 +232,7 @@ module Picky
233
232
  # Or go crazy and use 4 ranged categories for a space/time search! ;)
234
233
  #
235
234
  # === Parameters
236
- # * category_name: The category_name as used in #define_category.
235
+ # * category_name: The category_name as used in #category.
237
236
  # * range: The range (in the units of your data values) around the query point where we search for results.
238
237
  #
239
238
  # -----|<- range ->*------------|-----
@@ -241,7 +240,7 @@ module Picky
241
240
  # === Options
242
241
  # * precision: Default is 1 (20% error margin, very fast), up to 5 (5% error margin, slower) makes sense.
243
242
  # * anchor: Where to anchor the geo grid.
244
- # * ... all options of #define_category.
243
+ # * ... all options of #category.
245
244
  #
246
245
  def ranged_category category_name, range, options = {}
247
246
  precision = options.delete(:precision) || 1
@@ -251,19 +250,18 @@ module Picky
251
250
  #
252
251
  options = { partial: Partial::None.new }.merge options
253
252
 
254
- define_category category_name, options do |category|
255
- Wrappers::Category::Location.wrap category, range, precision, anchor
253
+ category category_name, options do |cat|
254
+ Wrappers::Category::Location.wrap cat, range, precision, anchor
256
255
  end
257
256
  end
258
- alias define_ranged_category ranged_category
259
257
 
260
258
  # HIGHLY EXPERIMENTAL Not correctly working yet. Try it if you feel "beta".
261
259
  #
262
260
  # Also a range search see #ranged_category, but on the earth's surface.
263
261
  #
264
262
  # Parameters:
265
- # * lat_name: The latitude's name as used in #define_category.
266
- # * lng_name: The longitude's name as used in #define_category.
263
+ # * lat_name: The latitude's name as used in #category.
264
+ # * lng_name: The longitude's name as used in #category.
267
265
  # * radius: The distance (in km) around the query point which we search for results.
268
266
  #
269
267
  # Note: Picky uses a square, not a circle. That should be ok for most usages.
@@ -317,7 +315,6 @@ module Picky
317
315
  ranged_category lng_name, radius*0.01796624, options.merge(from: lng_from)
318
316
 
319
317
  end
320
- alias define_geo_categories geo_categories
321
318
 
322
319
  def to_stats # :nodoc:
323
320
  stats = <<-INDEX
@@ -10,20 +10,13 @@ module Picky
10
10
  :possible_combinations,
11
11
  :to => :categories
12
12
 
13
- # TODO Remove in 4.0.
14
- #
15
- alias reload load
16
-
17
13
  # Define how the results of this index are identified.
18
14
  # (Shown in the client, for example)
19
15
  #
20
16
  # Default is the name of the index.
21
17
  #
22
18
  def result_identifier result_identifier = nil
23
- result_identifier ? define_result_identifier(result_identifier) : (@result_identifier || @name)
24
- end
25
- def define_result_identifier result_identifier
26
- @result_identifier = result_identifier
19
+ result_identifier ? (@result_identifier = result_identifier) : (@result_identifier || @name)
27
20
  end
28
21
 
29
22
  end