class Ferret::Search::ConstantScoreQuery

Summary ↑

ConstantScoreQuery is a way to turn a Filter into a Query. It matches all documents that its filter matches with a constant score. This is a very fast query, particularly when run more than once (since filters are cached). It is also used internally be RangeQuery.

Example ↑

Let's say for example that you often need to display all documents created on or after June 1st. You could create a ConstantScoreQuery like this;

query = ConstantScoreQuery.new(RangeFilter.new(:created_on, :>= => "200606"))

Once this is run once the results are cached and will be returned very quickly in future requests.

Public Class Methods

new(filter) → query click to toggle source

Create a ConstantScoreQuery which uses filter to match documents giving each document a constant score.

static VALUE
frb_csq_init(VALUE self, VALUE rfilter)
{
    Query *q;
    Filter *filter;
    Data_Get_Struct(rfilter, Filter, filter);
    q = csq_new(filter);

    Frt_Wrap_Struct(self, NULL, &frb_q_free, q);
    object_add(q, self);
    return self;
}