class EasySolr::Expressions
Attributes
nn_custom_links[RW]
Public Class Methods
new()
click to toggle source
# File lib/easy_solr/expressions.rb, line 6 def initialize @nn_solr_query_string = ' ' @nn_prefix_expression = [] @nn_params_array = [] @nn_query_string = '' end
Public Instance Methods
destroy!()
click to toggle source
query_string_for_solr()
click to toggle source
Description¶ ↑
生成 Solr 可以解析的字符串
Return¶ ↑
例如,将 solr_params = expr.solr_where(“ title = ? and id = ? ”, ‘奥迪’, ‘620460’).
solr_where(" second_editor_id = ? ", '138')
生成
title: 奥迪 id: 620460 second_editor_id: 138
# File lib/easy_solr/expressions.rb, line 46 def query_string_for_solr the_whole_solr_query_string = ' ' @nn_prefix_expression.each do |_query_item| the_whole_solr_query_string.concat(_query_item.traslate_to_solr_str) end the_whole_solr_query_string end
solr_where(prefix, *params)
click to toggle source
Description¶ ↑
拼接用户传递的参数,将其转换为Solr可以识别的 字符串
# File lib/easy_solr/expressions.rb, line 19 def solr_where(prefix, *params) prefix_array = prefix.split("and") params.each_with_index do |_key, _index| @nn_prefix_expression << \ ::EasySolr::QueryItem.new(nn_custom_links, prefix_array[_index], _key) end self end