The following code does not give any search result.
The error message is :
1 Documents indexed.
Index contains 1 documents.
Search for '<InsignificantQuery>' returned 0 hits
Any suggestion to how i will be able to work with text in the Swedish language
and with our chars "åäöÅÄÖ"?
Version used ZendFramework-1.8.4, linux platform.
<?php
define('ZEND_DIR','/home/netrogenic/html-nyss/ZendFramework-1.8.4/library');
ini_set('include_path',ini_get('include_path').":".ZEND_DIR);
require_once 'Zend/Search/Lucene.php';
setlocale(LC_ALL,"utf-8");
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
$index = new Zend_Search_Lucene('test_index',true);
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Keyword('link',"test",'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('title',"åäö",'utf-8'));
$index->addDocument($doc);
$index->commit();
echo $index->count()." Documents indexed.\n";
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
$index = new Zend_Search_Lucene('test_index');
$query = Zend_Search_Lucene_Search_QueryParser::parse("åäö",'utf-8');
$hits = $index->find($query);
echo "Index contains ".$index->count()." documents.\n\n";
echo "Search for '".$query."' returned " .count($hits). " hits\n\n";
foreach ($hits as $hit) {
echo $hit->link."\n";
echo "\tScore: ".sprintf('%.2f', $hit->score)."\n";
echo "\tTitle: ".$hit->title."\n";
echo "\t".$hit->title."\n\n";
}
?>