My create index function is as bellow
function create()
{
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive ());
$index = Zend_Search_Lucene::create('data/index');
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('title', 'a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('detail','a cheap car in town milage under 3000','utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('category', 'milage under 3000','utf-8'));
$index->addDocument($doc);
}
When user search for "a cheap car in town milage under 3000", I will split the query into 3 parts
$query1 = "a cheap car";
$query2 = "in town";
$query3 = " milage under 3000";
I want to search
$query1 in field "title", $query2 in field "detail", $query3 in field "category".
I also want to search number case insensitive and text case insensitive. How can I do it? I would need the actual code because I'm completely confused by the Zend Lucene docs, I don't know which code or query to use.
your query will be:
$query = Zend_Search_Lucene_Search_QueryParser::parse("title:($query1) detail:($query2) category:($query3)";
$hits = $index->find( $query);
Index is case-insensitive, unless explicitly set to case sensitive upon creation.