Php – Why Zend Lucene doesn’t find results but Luke does for the same fuzzy query

lucenePHPzend-framework

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

Best Answer

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

Zend_Search_Lucene_Search_Query_Fuzzy::setDefaultPrefixLength(1);
Related Topic