/* * call-seq: * iw.delete(field, term) -> iw * iw.delete(field, terms) -> iw * * Delete all documents in the index with the given +term+ or +terms+ in the * field +field+. You should usually have a unique document id which you use * with this method, rather then deleting all documents with the word "the" * in them. There are of course exceptions to this rule. For example, you may * want to delete all documents with the term "viagra" when deleting spam. */ static VALUE frb_iw_delete(VALUE self, VALUE rfield, VALUE rterm) { IndexWriter *iw = (IndexWriter *)DATA_PTR(self); if (TYPE(rterm) == T_ARRAY) { const int term_cnt = RARRAY_LEN(rterm); int i; char **terms = ALLOC_N(char *, term_cnt); for (i = 0; i < term_cnt; i++) { terms[i] = StringValuePtr(RARRAY_PTR(rterm)[i]); } iw_delete_terms(iw, frb_field(rfield), terms, term_cnt); free(terms); } else { iw_delete_term(iw, frb_field(rfield), StringValuePtr(rterm)); } return self; }