| Class | EstraierPure::Condition |
| In: |
lib/acts_as_searchable.rb
lib/vendor/estraierpure.rb |
| Parent: | Object |
Abstraction of search condition.
| SURE | = | 1 << 0 | option: check N-gram keys skipping by three | |
| USUAL | = | 1 << 1 | option: check N-gram keys skipping by two | |
| FAST | = | 1 << 2 | option: without TF-IDF tuning | |
| AGITO | = | 1 << 3 | option: with the simplified phrase | |
| NOIDF | = | 1 << 4 | option: check every N-gram key | |
| SIMPLE | = | 1 << 10 | option: check N-gram keys skipping by one |
Create a search condition object.
# File lib/vendor/estraierpure.rb, line 326
326: def initialize()
327: @phrase = nil
328: @attrs = []
329: @order = nil
330: @max = -1
331: @skip = 0
332: @options = 0
333: end
Add an expression for an attribute. `expr’ specifies an expression for an attribute. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 243
243: def add_attr(expr)
244: Utility::check_types({ expr=>String }) if $DEBUG
245: expr = expr.gsub(/[ \t\r\n\v\f]+/, " ")
246: expr = expr.strip.squeeze(" ")
247: @attrs.push(expr)
248: nil
249: end
Get expressions for attributes. The return value is expressions for attributes.
# File lib/vendor/estraierpure.rb, line 298
298: def attrs()
299: @attrs
300: end
Get the maximum number of retrieval. The return value is the maximum number of retrieval.
# File lib/vendor/estraierpure.rb, line 308
308: def max()
309: @max
310: end
Get options of retrieval. The return value is options by bitwise or.
# File lib/vendor/estraierpure.rb, line 318
318: def options()
319: @options
320: end
Get the order expression. The return value is the order expression.
# File lib/vendor/estraierpure.rb, line 303
303: def order()
304: @order
305: end
Get the search phrase. The return value is the search phrase.
# File lib/vendor/estraierpure.rb, line 293
293: def phrase()
294: @phrase
295: end
Set the maximum number of retrieval. `max’ specifies the maximum number of retrieval. By default, the number of retrieval is not limited. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 264
264: def set_max(max)
265: Utility::check_types({ max=>Integer }) if $DEBUG
266: @max = max if(max >= 0)
267: nil
268: end
Set options of retrieval. `options’ specifies options: `Condition::SURE’ specifies that it checks every N-gram key, `Condition::USU’, which is the default, specifies that it checks N-gram keys with skipping one key, `Condition::FAST’ skips two keys, `Condition::AGITO’ skips three keys, `Condition::NOIDF’ specifies not to perform TF-IDF tuning, `Condition::SIMPLE’ specifies to use simplified phrase. Each option can be specified at the same time by bitwise or. If keys are skipped, though search speed is improved, the relevance ratio grows less. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 286
286: def set_options(options)
287: Utility::check_types({ options=>Integer }) if $DEBUG
288: @options |= options
289: nil
290: end
Set the order of a condition object. `expr’ specifies an expression for the order. By default, the order is by score descending. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 253
253: def set_order(expr)
254: Utility::check_types({ expr=>String }) if $DEBUG
255: expr = expr.gsub(/[ \t\r\n\v\f]+/, " ")
256: expr = expr.strip.squeeze(" ")
257: @order = expr
258: nil
259: end
Set the search phrase. `phrase’ specifies a search phrase. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 233
233: def set_phrase(phrase)
234: Utility::check_types({ phrase=>String }) if $DEBUG
235: phrase = phrase.gsub(/[ \t\r\n\v\f]+/, " ")
236: phrase = phrase.strip.squeeze(" ")
237: @phrase = phrase
238: nil
239: end
Set the number of skipped documents. `skip’ specifies the number of documents to be skipped in the search result. The return value is always `nil’.
# File lib/vendor/estraierpure.rb, line 272
272: def set_skip(skip)
273: Utility::check_types({ skip=>Integer }) if $DEBUG
274: @skip = skip if(skip >= 0)
275: nil
276: end