EDIT:
I have managed to solve the problem by using:
+"lorem ipsum" +type:photo
+"lorem ipsum" +type:video
Another problem though is that the index is returning correct results but with wrong id (id is a primary key). More specifically, id fields returned are 1 less than real ids (id - 1) in the database which I use to build the index.
That's very strange.
What's wrong with these search queries:
"lorem ipsum" AND +type:photo
"lorem ipsum" AND +type:video
First query is supposed to find only results with type = photo, second one searches only videos. But they are both returning both photos and videos.
Here is how I build the index:
// create media index
$index = Zend_Search_Lucene::create('/data/media_index');
// get all media
$media = $this->_getTable('Media')->get();
// iterate through media and build index
foreach ($media as $m) {
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('id',
$m->id));
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('thumb_path',
$m->thumb_path));
$doc->addField(Zend_Search_Lucene_Field::Keyword('title',
$m->title));
$doc->addField(Zend_Search_Lucene_Field::UnStored('description',
$m->description));
$doc->addField(Zend_Search_Lucene_Field::Keyword('type',
$m->type));
$index->addDocument($doc);
}
// commit the index
$index->commit();
And here is how I search it:
$index = Zend_Search_Lucene::open('/data/media_index');
$this->view->photos = $index->find('"lorem ipsum" AND +type:photo');
$this->view->videos = $index->find('"lorem ipsum" AND +type:video');
Any ideas?