lib/picky/indexes.rb in picky-0.3.0 vs lib/picky/indexes.rb in picky-0.9.0
- old
+ new
@@ -9,37 +9,30 @@
def self.take_snapshot *args
configuration.take_snapshot *args
end
# Runs the indexers in parallel (index + cache).
#
- def self.index
+ def self.index randomly = true
Indexes.take_snapshot
# Run in parallel.
#
- timed_exclaim "INDEXING USING #{Cores.max_processors} PROCESSORS."
- Cores.forked self.fields, :randomly => true do |field|
- # Reestablish DB connection.
- #
- connect_backends
+ # TODO Make option to also use non-random.
+ # rake index:random (default)
+ # rake index:ordered
+ #
+ timed_exclaim "INDEXING USING #{Cores.max_processors} PROCESSORS, IN #{randomly ? 'RANDOM' : 'GIVEN'} ORDER."
+ Cores.forked self.fields, { :randomly => randomly } do |field, cores|
field.index
field.cache
end
timed_exclaim "INDEXING FINISHED."
end
def self.index_solr
configuration.index_solr
end
- # TODO Push into configuration.
- #
- def self.connect_backends
- configuration.types.each do |type|
- type.connect_backend
- end
- end
-
# Returns an array of fields.
#
# TODO Rewrite.
#
def self.fields
@@ -109,10 +102,12 @@
def self.generate_caches
each &:generate_caches
end
# Loads all indexes from the caches.
#
+ # TODO Rename load_indexes.
+ #
def self.load_from_cache
each &:load_from_cache
end
def self.reload
load_from_cache
@@ -130,14 +125,12 @@
end
# Removes the cache files.
#
def self.clear_caches
- each do |type|
- type.categories.each do |category|
- category.exact.delete_all
- category.partial.delete_all
- end
+ each_bundle do |exact, partial|
+ exact.delete_all
+ partial.delete_all
end
end
# Creates the directory structure for the indexes.
#
\ No newline at end of file