cheap_skate 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cheap_skate/index.rb +11 -8
- metadata +2 -2
data/lib/cheap_skate/index.rb
CHANGED
@@ -107,11 +107,11 @@ module CheapSkate
|
|
107
107
|
|
108
108
|
|
109
109
|
def parse_standard_query(params)
|
110
|
-
|
111
|
-
|
112
|
-
else
|
110
|
+
if params["q.op"] && !params["q.op"].empty?
|
111
|
+
or_and = [*params["q.op"]].first
|
112
|
+
else
|
113
|
+
or_and = schema.default_operator
|
113
114
|
end
|
114
|
-
|
115
115
|
dflt_field = case
|
116
116
|
when params["df"] then [*params["df"]].first
|
117
117
|
else schema.default_field
|
@@ -129,16 +129,17 @@ module CheapSkate
|
|
129
129
|
else
|
130
130
|
query.query = Ferret::Search::MatchAllQuery.new
|
131
131
|
end
|
132
|
-
if params['fq']
|
132
|
+
if params['fq'] && !params['fq'].empty?
|
133
133
|
query.filter = parse_filtered_query(params)
|
134
134
|
end
|
135
135
|
query
|
136
136
|
end
|
137
137
|
|
138
138
|
def parse_filtered_query(params)
|
139
|
-
|
140
|
-
|
141
|
-
else
|
139
|
+
if params["q.op"] && !params["q.op"].empty?
|
140
|
+
or_and = [*params["q.op"]].first
|
141
|
+
else
|
142
|
+
or_and = schema.default_operator
|
142
143
|
end
|
143
144
|
|
144
145
|
dflt_field = case
|
@@ -149,6 +150,7 @@ module CheapSkate
|
|
149
150
|
strict_parser = Ferret::QueryParser.new(:default_field=>dflt_field, :fields=>reader.tokenized_fields, :validate_fields=>true, :or_default=>(or_and=="OR"), :handle_parse_errors=>false)
|
150
151
|
bool = Ferret::Search::BooleanQuery.new
|
151
152
|
[*params['fq']].each do |fq|
|
153
|
+
next if fq.nil? or fq.empty?
|
152
154
|
if (filtq = strict_parser.parse(fq) && !filtq.to_s.empty?)
|
153
155
|
bool.add_query(filtq, :must)
|
154
156
|
else
|
@@ -158,6 +160,7 @@ module CheapSkate
|
|
158
160
|
end
|
159
161
|
end
|
160
162
|
unless bool.to_s.empty?
|
163
|
+
puts "We did something here."
|
161
164
|
return Ferret::Search::QueryFilter.new(bool)
|
162
165
|
end
|
163
166
|
nil
|