class Ferret::Search::WildcardQuery
Summary¶ ↑
WildcardQuery is a simple pattern matching query. There are two wild-card characters.
-
“*” which matches 0 or more characters
-
“?” which matches a single character
Example¶ ↑
query = WildcardQuery.new(:field, "h*og") # matches => "hog" # matches => "hot dog" query = WildcardQuery.new(:field, "fe?t") # matches => "feat" # matches => "feet" query = WildcardQuery.new(:field, "f?ll*") # matches => "fill" # matches => "falling" # matches => "folly"
Public Class Methods
Create a new WildcardQuery to search for
all terms where the pattern pattern
matches in the field
field
.
There is one option that you can set to change the behaviour of this query.
:max_terms
specifies the maximum number of terms to be added
to the query when it is expanded into a MultiTermQuery. Let's say for example
you have a million terms in your index and you let your users do wild-card
queries and one runs a search for “*”. You would end up with a very large
query which would use a lot of memory and take a long time to get results,
not to mention that it would probably match every document in the index. To
prevent queries like this crashing your application you can set
:max_terms
which limits the number of terms that get added to
the query. By default it is set to 512.
static VALUE frb_wcq_init(int argc, VALUE *argv, VALUE self) { return frb_mtq_init_specific(argc, argv, self, &wcq_new); }