[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);

	}

}

  

你可能感兴趣的:(thinkphp)