Sha256: f6fb1ec443f2ee2b9f6d0fbb179f1309da2e1d6cb9c25d0098f667c85de01826
Contents?: true
Size: 1.6 KB
Versions: 3
Compression:
Stored size: 1.6 KB
Contents
module Katello module Util module Search DISABLED_LUCENE_SPECIAL_CHARS = ['-', ':'].freeze def self.custom_analyzers { "kt_name_analyzer" => { "type" => "custom", "tokenizer" => "keyword", }, "autcomplete_name_analyzer" => { "type" => "custom", "tokenizer" => "keyword", "filter" => %w(standard lowercase ngram_filter), }, } end def self.custom_filters { "ngram_filter" => { "type" => "edgeNGram", "side" => "front", "min_gram" => 1, "max_gram" => 30, }, } end # Filter the search input, escaping unsupported lucene syntax (e.g. usage of - operator) def self.filter_input(search) return nil if search.nil? DISABLED_LUCENE_SPECIAL_CHARS.each do |chr| search = search.gsub(chr, '\\' + chr) end return search end def self.active_record_search_classes ignore_list = %w(Katello::CpConsumerUser Katello::Pool) classes = get_subclasses(ActiveRecord::Base) classes = classes.select { |c| !ignore_list.include?(c.name) && c.respond_to?(:index) } initial_list = classes.select { |c| c.superclass == ActiveRecord::Base } subclass_list = classes - initial_list initial_list + subclass_list end def self.get_subclasses(obj_class) classes = obj_class.subclasses subs = classes.collect { |c| get_subclasses(c) }.flatten classes + subs end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
katello-4.15.0 | app/lib/katello/util/search.rb |
katello-4.15.0.rc2 | app/lib/katello/util/search.rb |
katello-4.15.0.rc1 | app/lib/katello/util/search.rb |