Class: Ferret::Search::ConstantScoreQuery

Inherits:
Object
  • Object
show all
Defined in:
ext/r_search.c

Overview

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.