我使用charset utf 8,这是错误的:
Notice: Trying to get property of non-object in C:\wamp\www\zend-search-lucene\indexing.php on line 27
这是代码php:
<?php
require_once 'Zend/Search/Lucene.php';
$arr_data = array(0 => array( "products" => "Google suggest : pick right search keyword"),
1 => array("products" => "zend framework tutorial | part 9 Zend Auth"));
$lucene_index_path = 'data/';
$index = new Zend_Search_Lucene($lucene_index_path, true);
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
foreach($arr_data as $test) {
//create an cache index doc
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('products', $test->products, 'UTF-8')); **//LINE 27**
$index->addDocument($doc);
}
$index->commit();
$index->optimize();
答案 0 :(得分:3)
$doc->addField(Zend_Search_Lucene_Field::Text('products', $test['products'], 'UTF-8'));
将$test->products
更改为$test['products']