Reputation: 1635
I have a search form with a name, club, natranking, doublesranking and club field. I have selected a club from the selectbox, left the name field blank and clicked 'Search'. The result has no hits. There should be 3 as there are 3 records in the database that are part of that chosen club. Why is that?
Thx.
Controller class:
$search = $this->get('ewz_search.lucene');
// Create query
$terms = array(new Term($form->getData()->getName(), 'name'),
new Term($form->getData()->getClub(), 'club'),
new Term($form->getData()->getNatRanking(), 'natranking'),
new Term($form->getData()->getNatDoublesRanking(), 'doublesranking')
);
$signs = array(TRUE, TRUE, TRUE, TRUE);
$query = new MultiTerm($terms, $signs);
// Get results
$results = $search->find($query);
// Echo prints: "+name: +club:A.R.A. LA GANTOISE +natranking: +doublesranking:"
echo $query;
// This returns 0
die("debug: " . count($results);
//EDIT
This works (gives me 3 results):
$manual_query = "+name: +club:A.R.A. LA GANTOISE +natranking: +doublesranking:";
Upvotes: 3
Views: 507
Reputation: 1635
I casted the Multiterm object to a string and now it works. That's strange as the example in the docs clearly show that it should work without casting it to a string:
Examle from docs (http://framework.zend.com/manual/en/zend.search.lucene.query-api.html#zend.search.lucene.queries.multiterm-query)
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->addTerm(new Zend_Search_Lucene_Index_Term('word1'), true);
$query->addTerm(new Zend_Search_Lucene_Index_Term('word2', 'author'),
null);
$query->addTerm(new Zend_Search_Lucene_Index_Term('word3'), false);
$hits = $index->find($query);
Upvotes: 1