PHP 환경 (버전 5.4 이상)
Xunsearch Search Engine Server (다운로드 및 설치하십시오)
require_once '/path/to/sdk/php/lib/xs.php';
$ xs = new xs ( '/path/to/xunsearch/app.ini');
$ 검색 = $ xs-> 검색; $ search-> setfuzzy (); $ search-> setLimit (10); $ search-> setscwsmulti (3); $ search-> addweight ( 'title', 10); $ search-> addweight ( 'content', 5);
$ keyword = $ _get [ 'Q']; $ result = $ 검색-> 검색 ($ 키워드);
foreach ($ result as $ item) {
echo $ item-> 제목. '<br> ';;
echo $ item-> 컨텐츠. '<br><br> ';;
}
require_once '/path/to/sdk/php/lib/xs.php';
$ xs = new xs ( '/path/to/xunsearch/app.ini');
$ index = $ xs-> index;
$ pdo = new pdo ( 'mysql : host = localhost; dbname = test', 'username', 'password'); $ pdo-> stattribute (pdo :: attr_errmode, pdo :: errmode_exception); $ stmt = $ pdo-> 준비 ( 'select * from articles'); $ stmt-> execute (); $ data = $ stmt-> fetchall (pdo :: fetch_assoc);
foreach ($ data as $ item) {
$ doc = new xsdocument ();
$ doc-> setfields ($ item);
$ index-> update ($ doc);
}
$ index-> flushIndex ();