PhpRiot
Follow phpriot on Twitter
Sponsored Link
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
Free iPad/iPhone App
Available on the App Store

  • PHP manual
  • Zend Framework manual
  • Smarty manual
  • PHP articles
  • PHP training

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