을 처리합니다. Iam이 Zend_Search_Lucene을 사용합니다.Zend_Search_Luncene는 내 사이트에 Searchmachine을 구현하려는 Querys
public function create($config, $create = true)
{
$this->_config = $config;
// create a new index
if ($create) {
Zend_Search_Lucene_Analysis_Analyzer::setDefault(
new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive()
);
$this->_index = Zend_Search_Lucene::create(APPLICATION_PATH . $this->_config->index->path);
} else {
$this->_index = Zend_Search_Lucene::open(APPLICATION_PATH . $this->_config->index->path);
}
}
{
public function addToIndex($data)
$i = 0;
foreach ($data as $val) {
$scriptObj = new Sl_Model_Script();
$scriptObj->title = $val['title'];
$scriptObj->description = $val['description'];
$scriptObj->link = $val['link'];
$scriptObj->tutorials = $val['tutorials'];
$scriptObj->screenshot = $val['screenshot'];
$scriptObj->download = $val['download'];
$scriptObj->tags = $val['tags'];
$scriptObj->version = $val['version'];
$this->_dao->add($scriptObj);
$i++;
}
return $i;
}
/**
* Add to Index
*
* @param Sl_Interface_Model $scriptObj
*/
public function add(Sl_Interface_Model $scriptObj)
{
// UTF-8 for INDEX
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::text('title', $scriptObj->title, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('tags', $scriptObj->tags, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('version', $scriptObj->version, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('download', $scriptObj->download, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('link', $scriptObj->link));
$doc->addField(Zend_Search_Lucene_Field::text('description', $scriptObj->description, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('tutorials', $scriptObj->tutorials, 'utf-8'));
$doc->addField(Zend_Search_Lucene_Field::text('screenshot', $scriptObj->screenshot));
$this->_index->addDocument($doc);
}
을하지만 난과 함께 인덱스를 쿼리 할 때 :
인덱스는 다음과 같이 생성됩니다
$ 인덱스 -> 찾기 ('워드 프레스 2.8. 1' . '*');
메신저 다음과 같은 오류지고 ". 비 와일드 카드 문자 패턴의 시작 부분에 필요하다"
을
내 아이디어와 같은 문자열을 쿼리하는 방법은 무엇입니까? "wordpress"에 대한 쿼리는 excepted와 같이 작동합니다.
감사합니다. 그래서 "단어"하나만을 쿼리 할 수 있습니까? – opHASnoNAME
아니요, 후행 접두사가있는 여러 단어를 쿼리 할 수 있습니다. "kine"또는 "dict"로 시작하는 모든 문서를 찾으려면 다음을 입력하십시오. 이름 : kine * OR 이름 : dict * 기본적으로 또는 함께 절. 질문에 대한 답변이 있습니까? –