Abstract class representing a query to the index. There are a number of concrete Query implementations;
Explore these classes for the query right for you. The queries are passed to the Searcher#search* methods.
Queries have a boost value so that you can make the results of one query more important than the results of another query when combining them in a BooleanQuery. For example, documents on Rails. To avoid getting results for train rails you might also add the tern Ruby but Rails is the more important term so you’d give it a boost.
call-seq;
query.eql?(other_query) -> bool query == other_query -> bool
Return true if query equals other_query. Theoretically, two queries are equal if the always return the same results, no matter what the contents of the index. Practically, however, this is difficult to implement efficiently for queries like BooleanQuery since the ordering of clauses unspecified. “Ruby AND Rails” will not match “Rails AND Ruby” for example, although their result sets will be identical. Most queries should match as expected however.
static VALUE frb_q_eql(VALUE self, VALUE other) { GET_Q(); Query *oq; Data_Get_Struct(other, Query, oq); return q->eq(q, oq) ? Qtrue : Qfalse; }
call-seq;
query.eql?(other_query) -> bool query == other_query -> bool
Return true if query equals other_query. Theoretically, two queries are equal if the always return the same results, no matter what the contents of the index. Practically, however, this is difficult to implement efficiently for queries like BooleanQuery since the ordering of clauses unspecified. “Ruby AND Rails” will not match “Rails AND Ruby” for example, although their result sets will be identical. Most queries should match as expected however.
static VALUE frb_q_eql(VALUE self, VALUE other) { GET_Q(); Query *oq; Data_Get_Struct(other, Query, oq); return q->eq(q, oq) ? Qtrue : Qfalse; }
Return a hash value for the query. This is used for caching query results in a hash object.
static VALUE frb_q_hash(VALUE self) { GET_Q(); return INT2FIX(q->hash(q)); }
Returns an array of terms searched for by this query. This can be used for implementing an external query highlighter for example. You must supply a searcher so that the query can be rewritten and optimized like it would be in a real search.
static VALUE frb_q_get_terms(VALUE self, VALUE searcher) { VALUE rterms = rb_ary_new(); HashSet *terms = hs_new((hash_ft)&term_hash, (eq_ft)&term_eq, (free_ft)term_destroy); HashSetEntry *hse; GET_Q(); Searcher *sea = (Searcher *)DATA_PTR(searcher); Query *rq = sea->rewrite(sea, q); rq->extract_terms(rq, terms); q_deref(rq); for (hse = terms->first; hse; hse = hse->next) { Term *term = (Term *)hse->elem; rb_ary_push(rterms, frb_get_term(term->field, term->text)); } hs_destroy(terms); return rterms; }
Return a string representation of the query. Most of the time, passing this string through the Query parser will give you the exact Query you began with. This can be a good way to explore how the QueryParser works.
static VALUE frb_q_to_s(int argc, VALUE *argv, VALUE self) { GET_Q(); VALUE rstr, rfield; char *str; Symbol field = NULL; if (rb_scan_args(argc, argv, "01", &rfield)) { field = frb_field(rfield); } str = q->to_s(q, field); rstr = rb_str_new2(str); free(str); return rstr; }
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.