afsane
afsane

Reputation: 1919

Lucene Search doesn't find keyword indexed fields

i save my fieldes with this code:

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));
    }

}

i search the word with this code:

$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);

now it work perfect for unsorted and text fields , but it doesn`t search for keyword !!

Upvotes: 0

Views: 902

Answers (1)

Xodarap
Xodarap

Reputation: 11849

Are you sure you really want those fields to be keyword analyzed? The keyword analyzer puts the whole text of the field as one token, which you rarely want.

Upvotes: 1

Related Questions