Lucene Search找不到关键字索引字段

时间:2011-05-03 16:04:25

标签: zend-framework lucene field keyword

我使用此代码保存我的fieldes:

class Places_Search_Document extends Zend_Search_Lucene_Document{
public function __construct($class, $key, $title,$contents, $summary, $createdBy, $dateCreated)
    {
        $this->addField(Zend_Search_Lucene_Field::Keyword('docRef', "$class:$key"));
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('class', $class));
        $this->addField(Zend_Search_Lucene_Field::UnIndexed('key', $key));
        $this->addField(Zend_Search_Lucene_Field::Keyword('title', $title ,'UTF-8'));
        $this->addField(Zend_Search_Lucene_Field::unStored('contents', $contents , 'UTF-8'));
        $this->addField(Zend_Search_Lucene_Field::text('summary', $summary , 'UTF-8'));
        //$this->addField(Zend_Search_Lucene_Field::UnIndexed('createdBy', $createdBy));
        $this->addField(Zend_Search_Lucene_Field::Keyword('dateCreated', $dateCreated));
    }

}

我用这段代码搜索单词:

$index = Places_Search_Lucene::open(SearchIndexer::getIndexDirectory());
        $term = new Zend_Search_Lucene_Index_Term($q);
        $query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
        $results = $index->find($query);

现在它适用于未分类和文本字段,但它不会搜索关键字!!

1 个答案:

答案 0 :(得分:1)

您确定要确保对这些字段进行关键字分析吗?关键字分析器将字段的整个文本作为一个标记放置,您很少需要它。

相关问题