- index attributes of documents

This commit is contained in:
steinm 2012-10-09 09:57:28 +00:00
parent edb6486863
commit 694b0c598e
2 changed files with 25 additions and 3 deletions

View File

@ -47,6 +47,15 @@ class LetoDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
$this->addField(Zend_Search_Lucene_Field::Keyword('origfilename', $version->getOriginalFileName()));
if(!$nocontent)
$this->addField(Zend_Search_Lucene_Field::UnIndexed('created', $version->getDate()));
if($attributes = $version->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
if($attrdef->getValueSet() != '')
$this->addField(Zend_Search_Lucene_Field::Keyword('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue()));
else
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue()));
}
}
}
$this->addField(Zend_Search_Lucene_Field::Text('title', $document->getName()));
if($categories = $document->getCategories()) {
@ -56,6 +65,16 @@ class LetoDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
}
$this->addField(Zend_Search_Lucene_Field::Text('category', implode(' ', $names)));
}
if($attributes = $document->getAttributes()) {
foreach($attributes as $attribute) {
$attrdef = $attribute->getAttributeDefinition();
if($attrdef->getValueSet() != '')
$this->addField(Zend_Search_Lucene_Field::Keyword('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue()));
else
$this->addField(Zend_Search_Lucene_Field::Text('attr_'.str_replace(' ', '_', $attrdef->getName()), $attribute->getValue()));
}
}
$owner = $document->getOwner();
$this->addField(Zend_Search_Lucene_Field::Text('owner', $owner->getLogin()));
if($keywords = $document->getKeywords()) {

View File

@ -48,10 +48,13 @@ class LetoDMS_Lucene_Search {
* @param object $index lucene index
* @return object instance of LetoDMS_Lucene_Search
*/
function search($term, $owner, $status='', $categories=array()) { /* {{{ */
function search($term, $owner, $status='', $categories=array(), $fields=array()) { /* {{{ */
$query = '';
if($term)
$query .= trim($term);
if($fields) {
} else {
if($term)
$query .= trim($term);
}
if($owner) {
if($query)
$query .= ' && ';