16
16
* @package Zend_Search_Lucene
17
17
* @subpackage Document
18
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
19
* @license http://framework.zend.com/license/new-bsd New BSD License
32
32
* @package Zend_Search_Lucene
33
33
* @subpackage Document
34
* @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
34
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
35
35
* @license http://framework.zend.com/license/new-bsd New BSD License
37
37
class Zend_Search_Lucene_Field
41
public $name = 'body';
42
public $stringValue = null;
43
48
public $isStored = false;
44
49
public $isIndexed = true;
45
50
public $isTokenized = true;
48
53
public $storeTermVector = false;
57
* It's not stored directly in the index, but affects on normalizetion factor
50
61
public $boost = 1.0;
52
public function __construct($name, $stringValue, $isStored, $isIndexed, $isTokenized, $isBinary = false)
64
* Field value encoding.
74
* @param string $value
75
* @param string $encoding
76
* @param boolean $isStored
77
* @param boolean $isIndexed
78
* @param boolean $isTokenized
79
* @param boolean $isBinary
81
public function __construct($name, $value, $encoding, $isStored, $isIndexed, $isTokenized, $isBinary = false)
84
$this->value = $value;
58
* @todo Correct UTF-8 string should be required in future
59
* Until full UTF-8 support is not completed, string should be normalized to ANSII encoding
61
$this->stringValue = iconv(mb_detect_encoding($stringValue), 'ASCII//TRANSLIT', $stringValue);
62
//$this->stringValue = iconv('', 'ASCII//TRANSLIT', $stringValue);
87
$this->encoding = $encoding;
88
$this->isTokenized = $isTokenized;
64
$this->stringValue = $stringValue;
91
$this->isTokenized = false;
66
$this->isStored = $isStored;
67
$this->isIndexed = $isIndexed;
68
$this->isTokenized = $isTokenized;
69
$this->isBinary = $isBinary;
94
$this->isStored = $isStored;
95
$this->isIndexed = $isIndexed;
96
$this->isBinary = $isBinary;
71
98
$this->storeTermVector = false;
72
99
$this->boost = 1.0;
80
107
* @param string $name
81
108
* @param string $value
109
* @param string $encoding
82
110
* @return Zend_Search_Lucene_Field
84
static public function Keyword($name, $value)
112
public static function Keyword($name, $value, $encoding = '')
86
return new self($name, $value, true, true, false);
114
return new self($name, $value, $encoding, true, true, false);
94
122
* @param string $name
95
123
* @param string $value
124
* @param string $encoding
96
125
* @return Zend_Search_Lucene_Field
98
static public function UnIndexed($name, $value)
127
public static function UnIndexed($name, $value, $encoding = '')
100
return new self($name, $value, true, false, false);
129
return new self($name, $value, $encoding, true, false, false);
108
137
* @param string $name
109
138
* @param string $value
139
* @param string $encoding
110
140
* @return Zend_Search_Lucene_Field
112
static public function Binary($name, $value)
142
public static function Binary($name, $value)
114
return new self($name, $value, true, false, false, true);
144
return new self($name, $value, '', true, false, false, true);
122
152
* @param string $name
123
153
* @param string $value
154
* @param string $encoding
124
155
* @return Zend_Search_Lucene_Field
126
static public function Text($name, $value)
157
public static function Text($name, $value, $encoding = '')
128
return new self($name, $value, true, true, true);
159
return new self($name, $value, $encoding, true, true, true);
136
167
* @param string $name
137
168
* @param string $value
169
* @param string $encoding
138
170
* @return Zend_Search_Lucene_Field
140
static public function UnStored($name, $value)
172
public static function UnStored($name, $value, $encoding = '')
142
return new self($name, $value, false, true, true);
174
return new self($name, $value, $encoding, false, true, true);
178
* Get field value in UTF-8 encoding
182
public function getUtf8Value()
184
if (strcasecmp($this->encoding, 'utf8' ) == 0 ||
185
strcasecmp($this->encoding, 'utf-8') == 0 ) {
188
return iconv($this->encoding, 'UTF-8', $this->value);