0

I have this code:

    $query = '"ala ma"';

    try {
        $index = Zend_Search_Lucene::open(ROOT_PATH.'/data');
    }catch(Zend_Search_Lucene_Exception $e){
        $index = Zend_Search_Lucene::create(ROOT_PATH.'/data');
    }

    Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
    Zend_Search_Lucene_Analysis_Analyzer::setDefault(
        new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive()
    );

    $doc = new Zend_Search_Lucene_Document();
    $doc->addField(Zend_Search_Lucene_Field::text('title', 'ala ma kota ala ma kota ala', 'utf-8'));
    $index->addDocument($doc);
    $index->commit();

    $query = Zend_Search_Lucene_Search_QueryParser::parse($query);

$results = $index->find($query);


foreach ($results as $result){
    echo $query->htmlFragmentHighlightMatches($result->title, 'utf-8') . '<br></br>'; 
}

I need only mark found phrases and highlighter also select single words, in this case:

I need only mark: "ala ma", but highlighter also select last string word: ala

Anybody know the answer to this one?

micenst
  • 1
  • 1

0 Answers0