垂直搜索引擎Sphinx
$s = new SphinxClient(); // 实例化APi
$s->setServer(‘localhost’, 9312); // 设置服务端,第一个参数sphinx服务器地址,第二个sphinx监听端口
$s->SetConnectTimeout ( 30 ); //设置链接超时
$s->AddQuery(); //列表查询
$s->RunQueries (); //执行列表查询
$s->ResetFilters(); //清除过滤条件
s
−
>
B
u
i
l
d
E
x
c
e
r
p
t
s
(
s->BuildExcerpts(
s−>BuildExcerpts(docs, $index, $words);//生成简要
s
−
>
B
u
i
l
d
K
e
y
w
o
r
d
s
(
s->BuildKeywords(
s−>BuildKeywords(query, $index, $hits);//生成关键字
$s->GetLastError(); //错误
$s->GetLastWarning(); //警告
$s->FlushAttributes(); //索引刷入硬盘
$s->IsConnectError(); //链接错误
$s->ResetGroupBy(); //重设分组
$s->SetFieldWeights(array(‘sub_title’=>1));//加权最小为
s
−
>
S
e
t
I
D
R
a
n
g
e
(
s->SetIDRange(
s−>SetIDRange(min, $max); //ID范围
$s->SetIndexWeights(array(‘test1’=>1));//索引权重
$s->Status(); //服务是否可用
s
−
>
U
p
d
a
t
e
A
t
t
r
i
b
u
t
e
s
(
s->UpdateAttributes(
s−>UpdateAttributes(index, $attrs, $values);//更新硬盘索引
$s->setMatchMode(SPH_MATCH_ANY);//匹配模式
$s->setMaxQueryTime(3); //查询超时
$s->SetSelect ( $select ); //设置返回的字段
$s->SetArrayResult ( true ); //结果是否有ID
$s->SetLimits ( 0, 10 ); //显示数量:开始 量 最大量 右偏移量
$s->SetFilter ( ‘target_type’, $filtervals );//设置过滤,值列表
s
−
>
S
e
t
F
i
l
t
e
r
F
l
o
a
t
R
a
n
g
e
(
s->SetFilterFloatRange(
s−>SetFilterFloatRange(attribute, $min, $max);//浮动范围
s
−
>
S
e
t
F
i
l
t
e
r
R
a
n
g
e
(
s->SetFilterRange(
s−>SetFilterRange(attribute, $min, $max);//指定范围
s
−
>
S
e
t
R
e
t
r
i
e
s
(
s->SetRetries(
s−>SetRetries(count); //设置失败重试
$result = $s->query(“good”,“team”); //查询
希望可以帮助到您~