<commit_before>module Rooftop
  module AlgoliaSearch
    module PostSearching

      def self.included(base)
        base.extend ClassMethods

      end

      module ClassMethods

        def search(query, opts = {})
          opts = opts.with_indifferent_access
          search_index.search(query, opts).with_indifferent_access
        end
      end

    end
  end
end<commit_msg>Add ability to search by a specific index name, by passing into search() as the third arg.<commit_after>module Rooftop
  module AlgoliaSearch
    module PostSearching

      def self.included(base)
        base.extend ClassMethods

      end

      module ClassMethods

        def search(query, opts = {}, index_name=nil)
          opts = opts.with_indifferent_access
          if index_name
            index = replica_indexes.find {|i| i.name == index_name}
            raise ArgumentError, "Unknown search index name: #{index_name}" if index.nil?
          else
            index = search_index
          end
          index.search(query, opts).with_indifferent_access
        end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.05930656934306569, 'fraction_numerical': 0.0, 'mean_word_length': 2.1797101449275362, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6192177', 'n_tokens_mistral': 307, 'n_tokens_neox': 294, 'n_words': 86}