Sha256: 08573177fd86cdf7383a0557d282e5be201f38badb79673bb03951e4b2f8918e
Contents?: true
Size: 1.71 KB
Versions: 64
Compression:
Stored size: 1.71 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) } #we need index base classes first (TaskStatus) before child classes (PulpTaskStatus) 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
64 entries across 64 versions & 1 rubygems