title: Zend_Search_Lucene Help
body: <p><strong>EDIT:</strong></p>
  
  <p>I have managed to solve the problem by using:</p>
  
  <pre><code>+"lorem ipsum" +type:photo
  +"lorem ipsum" +type:video
  </code></pre>
  
  <p>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.</p>
  
  <p>That's very strange.</p>
  
  <hr>
  
  <p>What's wrong with these search queries:</p>
  
  <pre><code>"lorem ipsum" AND +type:photo
  "lorem ipsum" AND +type:video
  </code></pre>
  
  <p>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.</p>
  
  <p>Here is how I build the index:</p>
  
  <pre><code>    // create media index
      $index = Zend_Search_Lucene::create('/data/media_index');
      // get all media
      $media = $this-&gt;_getTable('Media')-&gt;get();
      // iterate through media and build index
      foreach ($media as $m) {
  
          $doc = new Zend_Search_Lucene_Document();
  
          $doc-&gt;addField(Zend_Search_Lucene_Field::UnIndexed('id',
                                                             $m-&gt;id));
          $doc-&gt;addField(Zend_Search_Lucene_Field::UnIndexed('thumb_path',
                                                             $m-&gt;thumb_path));
          $doc-&gt;addField(Zend_Search_Lucene_Field::Keyword('title',
                                                           $m-&gt;title));
          $doc-&gt;addField(Zend_Search_Lucene_Field::UnStored('description',
                                                            $m-&gt;description));
          $doc-&gt;addField(Zend_Search_Lucene_Field::Keyword('type',
                                                           $m-&gt;type));
  
          $index-&gt;addDocument($doc);
  
      }
      // commit the index
      $index-&gt;commit();
  </code></pre>
  
  <p>And here is how I search it:</p>
  
  <pre><code>    $index = Zend_Search_Lucene::open('/data/media_index');
      $this-&gt;view-&gt;photos = $index-&gt;find('"lorem ipsum" AND +type:photo');
      $this-&gt;view-&gt;videos = $index-&gt;find('"lorem ipsum" AND +type:video');
  </code></pre>
  
  <p>Any ideas?</p>