lib/picky/query/base.rb in picky-0.10.0 vs lib/picky/query/base.rb in picky-0.10.1
- old
+ new
@@ -8,17 +8,23 @@
include Helpers::Measuring
attr_writer :tokenizer
attr_accessor :reduce_to_amount, :weights
- # Run a query on the given text, with the offset and these indexes.
+ # Takes:
+ # * A number of indexes
+ # * Options hash (optional) with:
+ # * weigher: A weigher. Query::Weigher by default.
+ # * tokenizer: Tokenizers::Query.default by default.
+ # * weights: A hash of weights, or a Query::Weights object.
#
def initialize *index_types
options = Hash === index_types.last ? index_types.pop : {}
@index_types = index_types
@weigher = options[:weigher] || Weigher.new(index_types)
@tokenizer = options[:tokenizer] || Tokenizers::Query.default
- @weights = options[:weights] || Weights.new
+ weights = options[:weights] || Weights.new
+ @weights = Hash === weights ? Weights.new(weights) : weights
end
# Convenience method.
#
def search_with_text text, offset = 0
\ No newline at end of file