/*
* call-seq:
* term_enum.set_field(field) -> self
*
* Set the field for the term_enum. The field value should be a symbol as
* usual. For example, to scan all title terms you'd do this;
*
* term_enum.set_field(:title).each do |term, doc_freq|
* do_something()
* end
*/
static VALUE
frt_te_set_field(VALUE self, VALUE rfield)
{
TermEnum *te = (TermEnum *)DATA_PTR(self);
int field_num = 0;
VALUE rfnum_map = rb_ivar_get(self, id_fld_num_map);
VALUE rfnum = rb_hash_aref(rfnum_map, rfield);
if (rfnum != Qnil) {
field_num = FIX2INT(rfnum);
rb_ivar_set(self, id_field_num, rfnum);
} else {
Check_Type(rfield, T_SYMBOL);
rb_raise(rb_eArgError, "field %s doesn't exist in the index",
frt_field(rfield));
}
te->set_field(te, field_num);
return self;
}