Exemplo n.º 1
0
         }
         echo "不存在 {$word},";
         $docs = $log_ready ? $search->setFuzzy()->setLimit($limit)->search($word) : array();
         if (count($docs) === 0) {
             echo "并且没有相关的搜索词。";
         } else {
             echo "相关词:";
             foreach ($docs as $doc) {
                 echo "" . $doc->body . "  ";
             }
         }
         echo "\n";
     }
 } elseif ($put !== null) {
     echo "开始增加/更新搜索词 ... \n";
     $put = XSUtil::convertIn($put);
     foreach (explode(',', $put) as $tmp) {
         if (($pos = strpos($tmp, ':')) !== false) {
             $word = trim(substr($tmp, 0, $pos));
             $wdf = intval(substr($tmp, $pos + 1));
         } else {
             $word = trim($tmp);
             $wdf = 1;
         }
         addSearchLog($word, $wdf);
     }
 }
 // check flush
 if ($flush !== null || $del !== null) {
     echo "刷新已提交的日志索引 ...";
     $res = $xs->index->setDb($db)->flushIndex();
Exemplo n.º 2
0
require_once dirname(__FILE__) . '/XSUtil.class.php';
// check arguments
XSUtil::parseOpt(array('p', 'q', 'c', 'd', 's', 'project', 'query', 'db', 'limit', 'charset', 'sort', 'add-weight', 'scws-multi', 'cut-off'));
$project = XSUtil::getOpt('p', 'project', true);
$query = XSUtil::getOpt('q', 'query', true);
$hot = XSUtil::getOpt(null, 'hot');
$synonyms = XSUtil::getOpt(null, 'list-synonyms', false);
$terms = XSUtil::getOpt(null, 'terms');
$weights = XSUtil::getOpt(null, 'add-weight');
$info = XSUtil::getOpt(null, 'info');
$scws_multi = XSUtil::getOpt(null, 'scws-multi');
$cut_off = XSUtil::getOpt(null, 'cut-off');
// magick output charset
$charset = XSUtil::getOpt('c', 'charset');
XSUtil::setCharset($charset);
$query = XSUtil::convertIn($query);
// sort scheme
$sort = XSUtil::getOpt('s', 'sort');
if (XSUtil::getOpt('h', 'help') !== null || !is_string($project) || !$info && !$hot && !$synonyms && !is_string($query)) {
    $version = XS_PACKAGE_NAME . '/' . XS_PACKAGE_VERSION;
    echo <<<EOF
Quest - 搜索查询和测试工具 ({$version})

用法
    {$_SERVER['argv'][0]} [options] [-p|--project] <project> [[-q|--query] <query>]
\t
选项说明
    --project=<name|ini>
    -p <project> 用于指定要搜索的项目名称或项目配置文件的路径,
                 如果指定的是名称,则使用 ../app/<name>.ini 作为配置文件
    --charset=<gbk|utf-8>