name = $name; $this->value = $value; if (!$isBinary) { $this->encoding = $encoding; $this->isTokenized = $isTokenized; } else { $this->encoding = ''; $this->isTokenized = false; } $this->isStored = $isStored; $this->isIndexed = $isIndexed; $this->isBinary = $isBinary; $this->storeTermVector = false; $this->boost = 1.0; } /** * Constructs a String-valued Field that is not tokenized, but is indexed * and stored. Useful for non-text fields, e.g. date or url. * * @param string $name * @param string $value * @param string $encoding * @return Zend_Search_Lucene_Field */ public static function Keyword($name, $value, $encoding = '') { return new self($name, $value, $encoding, true, true, false); } /** * Constructs a String-valued Field that is not tokenized nor indexed, * but is stored in the index, for return with hits. * * @param string $name * @param string $value * @param string $encoding * @return Zend_Search_Lucene_Field */ public static function UnIndexed($name, $value, $encoding = '') { return new self($name, $value, $encoding, true, false, false); } /** * Constructs a Binary String valued Field that is not tokenized nor indexed, * but is stored in the index, for return with hits. * * @param string $name * @param string $value * @param string $encoding * @return Zend_Search_Lucene_Field */ public static function Binary($name, $value) { return new self($name, $value, '', true, false, false, true); } /** * Constructs a String-valued Field that is tokenized and indexed, * and is stored in the index, for return with hits. Useful for short text * fields, like "title" or "subject". Term vector will not be stored for this field. * * @param string $name * @param string $value * @param string $encoding * @return Zend_Search_Lucene_Field */ public static function Text($name, $value, $encoding = '') { return new self($name, $value, $encoding, true, true, true); } /** * Constructs a String-valued Field that is tokenized and indexed, * but that is not stored in the index. * * @param string $name * @param string $value * @param string $encoding * @return Zend_Search_Lucene_Field */ public static function UnStored($name, $value, $encoding = '') { return new self($name, $value, $encoding, false, true, true); } /** * Get field value in UTF-8 encoding * * @return string */ public function getUtf8Value() { if (strcasecmp($this->encoding, 'utf8' ) == 0 || strcasecmp($this->encoding, 'utf-8') == 0 ) { return $this->value; } else { return iconv($this->encoding, 'UTF-8', $this->value); } } }