Sha256: 11977c8fecd82524eb8b596a3529305833c220315d1a5ea8156a22840c57f307

Contents?: true

Size: 633 Bytes

Versions: 5

Compression:

Stored size: 633 Bytes

Contents

module QuickSearch::QueryFilter
  extend ActiveSupport::Concern

  include ActionView::Helpers::TextHelper

  private

  def filter_query(query)
    if query.match(/ -$/)
      query = query.sub(/ -$/,"")
    end
    query.gsub!('*', ' ')
    query.gsub!('!', ' ')
    query.gsub!('-', ' ') # Solr returns an error if multiple dashes appear at start of query string
    query.gsub!('\\', '')
    # query.gsub!('"', '')
    query.strip!
    query.squish!
    query.downcase! # FIXME: Do we really want to downcase everything?
    query = truncate(query, length: 100, separator: ' ', omission: '', escape: false)

    query
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
quick_search-core-0.2.0 app/controllers/concerns/quick_search/query_filter.rb
quick_search-core-0.1.1 app/controllers/concerns/quick_search/query_filter.rb
quick_search-core-0.1.0 app/controllers/concerns/quick_search/query_filter.rb
quick_search-core-0.0.1 app/controllers/concerns/quick_search/query_filter.rb
quick_search-core-0.0.1.test app/controllers/concerns/quick_search/query_filter.rb