7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
16
* @package Zend_Search_Lucene
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* A Term represents a word from text. This is the unit of search. It is
25
* composed of two elements, the text of the word, as a string, and the name of
26
* the field that the text occured in, an interned string.
28
* Note that terms may represent more than words from text fields, but also
29
* things like dates, email addresses, urls, etc.
32
* @package Zend_Search_Lucene
34
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
35
* @license http://framework.zend.com/license/new-bsd New BSD License
37
class Zend_Search_Lucene_Index_Term
40
* Field name or field number (depending from context)
57
public function __construct($text, $field = null)
59
$this->field = ($field === null)? Zend_Search_Lucene::getDefaultSearchField() : $field;
71
return $this->field . chr(0) . $this->text;
78
* @param integer $length
81
public static function getPrefix($str, $length)
85
while ($prefixBytes < strlen($str) && $prefixChars < $length) {
87
if ((ord($str[$prefixBytes]) & 0xC0) == 0xC0) {
89
if (ord($str[$prefixBytes]) & 0x20 ) {
91
if (ord($str[$prefixBytes]) & 0x10 ) {
97
if ($prefixBytes + $charBytes > strlen($str)) {
103
$prefixBytes += $charBytes;
106
return substr($str, 0, $prefixBytes);
110
* Get UTF-8 string length
115
public static function getLength($str)
119
while ($bytes < strlen($str)) {
121
if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
123
if (ord($str[$bytes]) & 0x20 ) {
125
if (ord($str[$bytes]) & 0x10 ) {
131
if ($bytes + $charBytes > strlen($str)) {
137
$bytes += $charBytes;