[xunsearch] 在thinkphp中使用xunsearch

file: XunSearchController.class.php

<?php
namespace Home\Controller;

include '/opt/xunsearch/sdk/php/lib/XS.php';

class XunSearchController extends HomeController{
	public function index(){
		$xs = new \XS('demo'); // 这里是关键, XS这个类不在Home\Controller空间中,是在公共空间,所以加反斜杠就不会提示class xxx not found 错误了
		$search = $xs->search;
		$search->setCharset('UTF-8');
		$query = '项目';
		$search->setQuery($query);
		$docs = $search->search();
		dump($docs);
	}
}

  

posted @ 2015-04-11 11:47  捕蛇者说  阅读(1738)  评论(0编辑  收藏  举报