Hello,
if your index is already created with multiple fields per name(like the example), you can change the functions getField and addField (and create the new function getFields) in the Document.php of the Framework like this:
PHP Code:
public function addField(Zend_Search_Lucene_Field $field)
{
//$this->_fields[$field->name] = $field;
if ($this->_fields[$field->name] === null) {
$this->_fields[$field->name] = $field;
} else if ($this->_fields[$field->name] instanceof Zend_Search_Lucene_Field ) {
$_newArray = array();
array_push($_newArray, $this->_fields[$field->name]);
array_push($_newArray, $field);
$this->_fields[$field->name] = $_newArray;
} else if (is_array($this->_fields[$field->name])) {
array_push($this->_fields[$field->name], $field);
} else {
throw new Zend_Search_Lucene_Exception("unknown fieldType : " + getType($field));
}
}
public function getField($fieldName)
{
//return $this->_fields[$fieldName];
if (!array_key_exists($fieldName, $this->_fields)) {
throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document.");
} else if ($this->_fields[$fieldName] instanceof Zend_Search_Lucene_Field ) {
return $this->_fields[$fieldName];
} else if (is_array($this->_fields[$fieldName])) {
return $this->_fields[$fieldName][0];
} else {
throw new Zend_Search_Lucene_Exception("unknown fieldType : " + getType($field));
}
}
public function getFields($fieldName)
{
if (!array_key_exists($fieldName, $this->_fields)) {
throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document.");
} else if ($this->_fields[$fieldName] instanceof Zend_Search_Lucene_Field ) {
return array($this->_fields[$fieldName]);
} else if (is_array($this->_fields[$fieldName])) {
return $this->_fields[$fieldName];
} else {
throw new Zend_Search_Lucene_Exception("unknown fieldType : " + getType($field));
}
}