Sha256: 61b8a26b961edc7dc8ba5e2b50ba3ed22a05a06a5ec0210e04c83c095b3a67d3

Contents?: true

Size: 639 Bytes

Versions: 34

Compression:

Stored size: 639 Bytes

Contents

module QueryHelper
  def get_filter_tag(boolean_query)
    connection.searches.last[:fq].each do |fq|
      if match = fq.match(/^\{!tag=(.+)\}#{Regexp.escape(boolean_query)}$/)
        return match[1]
      end
    end
    nil
  end

  def subqueries(param)
    q = connection.searches.last[:q]
    subqueries = []
    subqueries = q.scan(%r(_query_:"\{!dismax (.*?)\}(.*?)"))
    subqueries.map do |subquery|
      params = {}
      subquery[0].scan(%r((\S+?)='(.+?)')) do |key, value|
        params[key.to_sym] = value
      end
      unless subquery[1].empty?
        params[:v] = subquery[1]
      end
      params
    end
  end
end

Version data entries

34 entries across 34 versions & 8 rubygems

Version Path
sunspot_stats-0.0.7 spec/helpers/query_helper.rb
sunspot_stats-0.0.6 spec/helpers/query_helper.rb
sunspot_suggest-0.0.3 spec/helpers/query_helper.rb
sunspot_suggest-0.0.2 spec/helpers/query_helper.rb
sunspot_suggest-0.0.1 spec/helpers/query_helper.rb
sunspot-2.0.0 spec/helpers/query_helper.rb
sunspot-2.0.0.pre.130115 spec/helpers/query_helper.rb
gojee-sunspot-2.0.5 spec/helpers/query_helper.rb
sunspot-2.0.0.pre.120925 spec/helpers/query_helper.rb
sunspot_solr-2.0.0.pre.120924 sunspot/spec/helpers/query_helper.rb
sunspot_rails-2.0.0.pre.120924 sunspot/spec/helpers/query_helper.rb
sunspot-2.0.0.pre.120924 sunspot/spec/helpers/query_helper.rb
gojee-sunspot-2.0.4 spec/helpers/query_helper.rb
gojee-sunspot-2.0.2 spec/helpers/query_helper.rb
sunspot_stats-0.0.5 spec/helpers/query_helper.rb
sunspot_stats-0.0.4 spec/helpers/query_helper.rb
sunspot-2.0.0.pre.120720 spec/helpers/query_helper.rb
sunspot_stats-0.0.3 spec/helpers/query_helper.rb
sunspot-1.3.3 spec/helpers/query_helper.rb
sunspot-1.3.2 spec/helpers/query_helper.rb