What is the best way to do a many-to-many relationship in Zend_Search_Lucene? 
For instance, suppose I have index of a blog and I wish for users to be able
to search by a tag.  A post can have many tags and a tag can have many
posts.

The approach I would like to take to index is:

<?php
foreach ($tags as $tag)
{
  $document->addField(Zend_Search_Lucene_Field::Keyword($tag, 'tag'));
}
?>

I can then search the index by:
<?php
      $userQuery = Zend_Search_Lucene_Search_QueryParser::parse($query);
      
      $tagTerm = new Zend_Search_Lucene_Index_Term($tag, 'tag');
      $tagQuery = new Zend_Search_Lucene_Search_Query_Term($tagTerm);
      
      $query = new Zend_Search_Lucene_Search_Query_Boolean();
      $query->addSubquery($userQuery, true);
      $query->addSubquery($tagQuery, true);
?>

However, it seems only the last $tag is indexed using this method.  How can
I do this?

Carl
-- 
View this message in context: 
http://www.nabble.com/Lucene-and-n%3Am-tf4449653s16154.html#a12695579
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to