/*
* call-seq:
* MultiTermQuery.new(field, options = {}) -> multi_term_query
*
* Create a new MultiTermQuery on field +field+. You will also need to add
* terms to the query using the MultiTermQuery#add_term method.
*
* There are several options available to you when creating a
* MultiTermQueries;
*
* === Options
*
* :max_terms:: You can specify the maximum number of terms that can be
* added to the query. This is to prevent memory usage overflow,
* particularly when don't directly control the addition of
* terms to the Query object like when you create Wildcard
* queries. For example, searching for "content:*" would cause
* problems without this limit.
* :min_score:: The minimum score a term must have to be added to the query.
* For example you could implement your own wild-card queries
* that gives matches a score. To limit the number of terms
* added to the query you could set a lower limit to this score.
* FuzzyQuery in particular makes use of this parameter.
*/
static VALUE
frt_mtq_init(int argc, VALUE *argv, VALUE self)
{
VALUE rfield, roptions;
float min_score = 0.0;
int max_terms = FIX2INT(frt_mtq_get_dmt(self));
Query *q;
if (rb_scan_args(argc, argv, "11", &rfield, &roptions) == 2) {
VALUE v;
if (Qnil != (v = rb_hash_aref(roptions, sym_max_terms))) {
max_terms = FIX2INT(v);
}
if (Qnil != (v = rb_hash_aref(roptions, sym_min_score))) {
min_score = (float)NUM2DBL(v);
}
}
q = multi_tq_new_conf(frt_field(rfield), max_terms, min_score);
Frt_Wrap_Struct(self, NULL, &frt_q_free, q);
object_add(q, self);
return self;
}