views:

33

answers:

1

I am using Zend Search Lucene and if the user types in Vibrant Bouquet into the search box, results with the word "Vibrant" or the word "bouquet" (or both obviously) are returned. What I want is only to return those results with both words.

Obviously I can do this by typing AND between the words, but as far as I can tell Lucene implicitly puts OR between each word as it is; is it possible to change this so that it implicitly puts AND between each word so that the default behaviour for searches is to find all words, not just one or more?

I could do this with a string replace on the search term to replace spaces with AND, but that could cause issues with stopping the user typing in more complex queries.

+2  A: 

Hi, I've searched google for you :

The default boolean operator may be set or retrieved with the Zend_Search_Lucene_Search_QueryParser::setDefaultOperator($operator) and Zend_Search_Lucene_Search_QueryParser::getDefaultOperator() methods, respectively.

These methods operate with the Zend_Search_Lucene_Search_QueryParser::B_AND and Zend_Search_Lucene_Search_QueryParser::B_OR constants.

http://framework.zend.com/manual/en/zend.search.lucene.query-language.html

Guillaume Lebourgeois
Thanks, I was looking on the query construction api page.
Gnuffo1