PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Range Query

Range queries are intended for searching terms within specified interval.

Query string:

mod_date:[20020101 TO 20030101]
title:{Aida TO Carmen}

or

Query construction by API:

<?php
$from 
= new Zend_Search_Lucene_Index_Term('20020101''mod_date');
$to   = new Zend_Search_Lucene_Index_Term('20030101''mod_date');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 
$from$totrue // inclusive
             
);
$hits  $index->find($query);

Term fields are optional. Zend_Search_Lucene searches through all fields if the field is not specified:

<?php
$from 
= new Zend_Search_Lucene_Index_Term('Aida');
$to   = new Zend_Search_Lucene_Index_Term('Carmen');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 
$from$tofalse // non-inclusive
             
);
$hits  $index->find($query);

Either (but not both) of the boundary terms may be set to NULL. Zend_Search_Lucene searches from the beginning or up to the end of the dictionary for the specified field(s) in this case:

<?php
// searches for ['20020101' TO ...]
$from = new Zend_Search_Lucene_Index_Term('20020101''mod_date');
$query = new Zend_Search_Lucene_Search_Query_Range(
                 
$fromnulltrue // inclusive
             
);
$hits  $index->find($query);

Zend Framework