### Home Classes Methods

### In Files

- ext/r_search.c

### Parent

Ferret::Search::Query

### Methods

- ::new

### Files

- MIT-LICENSE
- README
- TODO
- TUTORIAL

### Class/Module Index

Quicksearch

- Ferret
- Ferret::Analysis
- Ferret::Analysis::Analyzer
- Ferret::Analysis::AsciiLetterAnalyzer
- Ferret::Analysis::AsciiLetterTokenizer
- Ferret::Analysis::AsciiLowerCaseFilter
- Ferret::Analysis::AsciiStandardAnalyzer
- Ferret::Analysis::AsciiStandardTokenizer
- Ferret::Analysis::AsciiWhiteSpaceAnalyzer
- Ferret::Analysis::AsciiWhiteSpaceTokenizer
- Ferret::Analysis::HyphenFilter
- Ferret::Analysis::LetterAnalyzer
- Ferret::Analysis::LetterTokenizer
- Ferret::Analysis::LowerCaseFilter
- Ferret::Analysis::MappingFilter
- Ferret::Analysis::PerFieldAnalyzer
- Ferret::Analysis::RegExpAnalyzer
- Ferret::Analysis::RegExpTokenizer
- Ferret::Analysis::StandardAnalyzer
- Ferret::Analysis::StandardTokenizer
- Ferret::Analysis::StemFilter
- Ferret::Analysis::StopFilter
- Ferret::Analysis::Token
- Ferret::Analysis::TokenStream
- Ferret::Analysis::WhiteSpaceAnalyzer
- Ferret::Analysis::WhiteSpaceTokenizer
- Ferret::BlankSlate
- Ferret::BoostMixin
- Ferret::Browser
- Ferret::Browser::Controller
- Ferret::Browser::Delegator
- Ferret::Browser::DocumentController
- Ferret::Browser::ErrorController
- Ferret::Browser::HelpController
- Ferret::Browser::HomeController
- Ferret::Browser::TermController
- Ferret::Browser::TermVectorController
- Ferret::Browser::ViewHelper
- Ferret::Document
- Ferret::Field
- Ferret::FieldSymbol
- Ferret::FieldSymbolMethods
- Ferret::FileNotFoundError
- Ferret::Index
- Ferret::Index::FieldInfo
- Ferret::Index::FieldInfos
- Ferret::Index::Index
- Ferret::Index::IndexReader
- Ferret::Index::IndexWriter
- Ferret::Index::LazyDoc
- Ferret::Index::LazyDoc::LazyDocData
- Ferret::Index::TermDocEnum
- Ferret::Index::TermEnum
- Ferret::Index::TermVector
- Ferret::Index::TermVector::TVOffsets
- Ferret::Index::TermVector::TVTerm
- Ferret::ParseError
- Ferret::QueryParser
- Ferret::QueryParser::QueryParseException
- Ferret::Search
- Ferret::Search::BooleanQuery
- Ferret::Search::BooleanQuery::BooleanClause
- Ferret::Search::ConstantScoreQuery
- Ferret::Search::Explanation
- Ferret::Search::Filter
- Ferret::Search::FilteredQuery
- Ferret::Search::FuzzyQuery
- Ferret::Search::Hit
- Ferret::Search::MatchAllQuery
- Ferret::Search::MultiSearcher
- Ferret::Search::MultiTermQuery
- Ferret::Search::PhraseQuery
- Ferret::Search::PrefixQuery
- Ferret::Search::Query
- Ferret::Search::QueryFilter
- Ferret::Search::RangeFilter
- Ferret::Search::RangeQuery
- Ferret::Search::Searcher
- Ferret::Search::Sort
- Ferret::Search::SortField
- Ferret::Search::Spans
- Ferret::Search::Spans::SpanFirstQuery
- Ferret::Search::Spans::SpanMultiTermQuery
- Ferret::Search::Spans::SpanNearQuery
- Ferret::Search::Spans::SpanNotQuery
- Ferret::Search::Spans::SpanOrQuery
- Ferret::Search::Spans::SpanPrefixQuery
- Ferret::Search::Spans::SpanTermQuery
- Ferret::Search::TermQuery
- Ferret::Search::TopDocs
- Ferret::Search::TypedRangeFilter
- Ferret::Search::TypedRangeQuery
- Ferret::Search::WildcardQuery
- Ferret::StateError
- Ferret::Store
- Ferret::Store::Directory
- Ferret::Store::FSDirectory
- Ferret::Store::Lock
- Ferret::Store::Lock::LockError
- Ferret::Store::RAMDirectory
- Ferret::Utils
- Ferret::Utils::BitVector
- Ferret::Utils::MultiMapper
- Ferret::Utils::PriorityQueue
- WEBrick
- WEBrick::FerretBrowserHandler
- Date
- DateTime
- FileUtils
- Float
- Integer
- String
- Symbol
- Time

No matching classes.

# Ferret::Search::TypedRangeQuery

## Summary

TypedRangeQuery is used to find documents with terms in a range. RangeQuerys are usually used on untokenized fields like date fields or number fields. TypedRangeQuery is particularly useful for fields with unnormalized numbers, both positive and negative, integer and float.

## Example

To find all documents written between January 1st 2006 and January 26th 2006 inclusive you would write the query like this;

    query = RangeQuery.new(:create_date, :>= "-1.0", :<= "10.0")

## Performance Note

TypedRangeQuery works by converting all the terms in a field to numbers and then comparing those numbers with the range bondaries. This can have quite an impact on performance on large indexes so in those cases it is usually better to use a standard RangeQuery. This will require a little work on your behalf. See RangeQuery for notes on how to do this.

### Public Class Methods

new(field, options = {}) → range_query click to toggle source

Create a new TypedRangeQuery on field `field`. This differs from the standard RangeQuery in that it allows range queries with unpadded numbers, both positive and negative, integer and float. You can even use hexadecimal numbers. However it could be a lot slower than the standard RangeQuery on large indexes.

There are two ways to build a range query. With the old-style options; `:lower`, `:upper`, `:include_lower` and `:include_upper` or the new style options; +:<+, +:<=+, +:>+ and +:>=+. The options' names should speak for themselves. In the old-style options, limits are inclusive by default.

## Examples

    q = TypedRangeQuery.new(:date, :lower => "0.1", :include_lower => false)
    # is equivalent to
    q = TypedRangeQuery.new(:date, :< => "0.1")
    # is equivalent to
    q = TypedRangeQuery.new(:date, :lower_exclusive => "0.1")

    # Note that you numbers can be strings or actual numbers
    q = TypedRangeQuery.new(:date, :lower => "-12.32", :upper => 0.21)
    # is equivalent to
    q = TypedRangeQuery.new(:date, :>= => "-12.32", :<= => 0.21)

    static VALUE
    frb_trq_init(VALUE self, VALUE rfield, VALUE roptions)
    {
        Query *q;
        char *lterm = NULL;
        char *uterm = NULL;
        bool include_lower = false;
        bool include_upper = false;

        get_range_params(roptions, &lterm, &uterm, &include_lower, &include_upper);
        q = trq_new(frb_field(rfield),
                    lterm, uterm,
                    include_lower, include_upper);
        Frt_Wrap_Struct(self, NULL, &frb_q_free, q);
        object_add(q, self);
        return self;
    }

[Validate]

Generated with the Darkfish Rdoc Generator 2.