views:

242

answers:

2

Hello I am coding search engine using Zend Framework Lucene. I'm trying to make fuzzy query: "name:sxample~" When I put it into Luke - it founds 14 results (all with word "sample"). When I use my php code -

$query = 'name:sxample~';
  $query = Zend_Search_Lucene_Search_QueryParser::parse($query,'utf-8');

  try {
   $hits = $index->find($query);
  }
  catch (Zend_Search_Lucene_Exception $ex) {
   $hits = array();
  }

- the hits array is empty. I guess indexing is ok, while Luke and ZF uses the same files. I'm using Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8 as my analyzer. Can you tell me what is wrong with my php query or is it maybe ZF bug?

Greetings

A: 

Have you tried putting a var_dump of $ex inside the catch-statement to ensure you don't get an exception, thus setting the $hits-variable to an empty array?

PatrikAkerstrand
I've tried it - the query is correct, no exception.
pbrodka
+3  A: 

After research I found what to change - if misspeled letter is in the first 3 letters - then it isn't found. I had to set :

Zend_Search_Lucene_Search_Query_Fuzzy::setDefaultPrefixLength(1);
pbrodka