lib/active_groonga/base.rb in activegroonga-0.0.1 vs lib/active_groonga/base.rb in activegroonga-0.0.2

- old
+ new

@@ -588,13 +588,13 @@ unless File.exist?(database_directory) FileUtils.mkdir_p(database_directory) end database_file = File.join(database_directory, "database.groonga") if File.exist?(database_file) - Groonga::Database.new(database_file) + @@database = Groonga::Database.new(database_file) else - Groonga::Database.create(:path => database_file) + @@database = Groonga::Database.create(:path => database_file) end self.database_directory = database_directory end end @@ -646,10 +646,14 @@ key = conditions.delete(index_definition.column) index_records = index.search(key, :result => index_records) end end if index_records - sorted_records = index_records.sort([".:score"], :limit => limit) + sorted_records = index_records.sort([ + :key => ".:score", + :order => :descending, + ], + :limit => limit) limit = sorted_records.size target_records = sorted_records.records(:order => :ascending).collect do |record| index_record_id = record.value.unpack("i")[0] index_record = Groonga::Record.new(index_records, index_record_id) target_record = index_record.key