Based on the following search index build code I am trying to figure out how
to add "filtering by secondary fields" to a query. I will explain below.
Here is the search index build code.
<?php
// Create search index
$index = Zend_Search_Lucene::create($indexPath);
$articles = getArticles();
foreach($articles as $article) {
// Create new Document
$doc = new Zend_Search_Lucene_Document();
// Index article id
$doc->addField(Zend_Search_Lucene_Field::Keyword('article_id',
$article['id']));
// Index author id
$doc->addField(Zend_Search_Lucene_Field::Keyword('author_id',
$article['author_id']));
// Index category id
$doc->addField(Zend_Search_Lucene_Field::Keyword('category_id',
$article['category_id']));
// Index title
$doc->addField(Zend_Search_Lucene_Field::UnStored('title',
$article['title']));
// Index body
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents',
$article['body']));
// Add document to the index
$index->addDocument($doc);
}
$index->optimize();
$index->commit();
Here is an example of performing a search query.
$terms = "keywords here";
$query = Zend_Search_Lucene_Search_QueryParser::parse($terms);
$hits = $index->find($query);
Based upon the above index build code, how could i "filter" the given search
query code to allow me to add filters to the query.
Filters such as
1) limiting the search query results to a list of author ids
2) limiting the search query results to a list of category ids
Any help on this would be much appreciated. I found the ZF manual confusing
when it comes to building query building.
Thanks!
--
View this message in context: http://www.nabble.com/Zend_Search_Lucene---How-to-add-filtering-to-queries--tp25137622p25137622.html
Sent from the Zend MFS mailing list archive at Nabble.com.
没有评论:
发表评论