Sha256: cdef4362399a74bdf21203441eda06cf588dae765225c4391ca5fccd6102e3e3

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

#
#
class Category

  attr_reader :indexed_exact

  # TODO Move to Index.
  #
  def generate_qualifiers_from options
    options[:qualifiers] || options[:qualifier] && [options[:qualifier]]
  end

  # Loads the index from cache.
  #
  def load_from_cache
    timed_exclaim %Q{"#{identifier}": Loading index from cache.}
    indexed_exact.load
    indexed_partial.load
  end
  alias reload load_from_cache

  # Loads, analyzes, and clears the index.
  #
  # Note: The idea is not to run this while the search engine is running.
  #
  def analyze collector
    collector[identifier] = {
      :exact   => Analyzer.new.analyze(indexed_exact),
      :partial => Analyzer.new.analyze(indexed_partial)
    }
    collector
  end

  # Gets the weight for this token's text.
  #
  def weight token
    bundle_for(token).weight token.text
  end

  # Gets the ids for this token's text.
  #
  def ids token
    bundle_for(token).ids token.text
  end

  # Returns the right index bundle for this token.
  #
  def bundle_for token
    token.partial? ? indexed_partial : indexed_exact
  end

  # The partial strategy defines whether to really use the partial index.
  #
  def indexed_partial
    @partial_strategy.use_exact_for_partial? ? @indexed_exact : @indexed_partial
  end

  #
  #
  def combination_for token
    weight(token) && Query::Combination.new(token, self)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.6.0 lib/picky/category_indexed.rb