可以将安装目录下的核心代码拷贝到Vendor中。

Tp中使用Xunsearch_项目测试

Tp中使用Xunsearch_php_02

命名为xunsearch。

然后引入使用。

vendor('xunsearch.lib.XS');
$xs = new \XS('demo');   // 自动使用 $prefix/sdk/php/app/demo.ini 作项目配置文件
$docs = $xs->search->search('测试');
print_r($docs);
Array
(
    [0] => XSDocument Object
        (
            [_data:XSDocument:private] => Array
                (
                    [pid] => 2
                    [subject] => 测试第二篇
                    [chrono] => 1314336160
                    [message] => 这里是第二篇文章的内容
                )

            [_terms:XSDocument:private] => 
            [_texts:XSDocument:private] => 
            [_charset:XSDocument:private] => UTF-8
            [_meta:XSDocument:private] => Array
                (
                    [docid] => 2
                    [rank] => 1
                    [ccount] => 0
                    [percent] => 100
                    [weight] => 0.11754341423512
                )

        )

    [1] => XSDocument Object
        (
            [_data:XSDocument:private] => Array
                (
                    [pid] => 1
                    [subject] => 关于 xunsearch 的 DEMO 项目测试
                    [chrono] => 1314336158
                    [message] => 项目测试是一个很有意思的行为!
                )

            [_terms:XSDocument:private] => 
            [_texts:XSDocument:private] => 
            [_charset:XSDocument:private] => UTF-8
            [_meta:XSDocument:private] => Array
                (
                    [docid] => 1
                    [rank] => 2
                    [ccount] => 0
                    [percent] => 98
                    [weight] => 0.11563987284899
                )

        )

    [2] => XSDocument Object
        (
            [_data:XSDocument:private] => Array
                (
                    [pid] => 3
                    [subject] => 项目测试第三篇
                    [chrono] => 1314336168
                    [message] => 俗话说,无三不成礼,所以就有了第三篇
                )

            [_terms:XSDocument:private] => 
            [_texts:XSDocument:private] => 
            [_charset:XSDocument:private] => UTF-8
            [_meta:XSDocument:private] => Array
                (
                    [docid] => 3
                    [rank] => 3
                    [ccount] => 0
                    [percent] => 98
                    [weight] => 0.11554631590843
                )

        )

)