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

Wildcard Query

Wildcard queries can be used to search for documents containing strings matching specified patterns.

The '?' symbol is used as a single character wildcard.

The '*' symbol is used as a multiple character wildcard.

Query string:

field1:test*

or

Query construction by API:

<?php
$pattern 
= new Zend_Search_Lucene_Index_Term('test*''field1');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits  $index->find($query);

The term field is optional. Zend_Search_Lucene searches through all fields on each document if a field is not specified:

<?php
$pattern 
= new Zend_Search_Lucene_Index_Term('test*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
$hits  $index->find($query);

Zend Framework