狮身人面像搜索 - 新手
我已经成功地让 Sphinx 运行并使用以下内容对表进行索引: emp_id、emp_name、emp_department、emp_gender、emp_join_date、emp_notes
如何使用 Sphinx 返回 emp_gender 为“男性”的结果?
<?php
include ('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer( "SPHINX2", 3312 );
$cl->SetMatchMode( SPH_MATCH_EXTENDED);
$result = $cl->Query( "male","sphinx_search");
?>
上面的代码在任何地方返回male,包括emp_notes字段和emp_gender字段。请建议我如何定位列。像@emp_gendermale这样的东西会起作用吗?它没有按预期返回结果
I have managed to get Sphinx running to index a table with the following:
emp_id, emp_name, emp_department, emp_gender, emp_join_date, emp_notes
How do I use Sphinx to return results where emp_gender is "male"?
<?php
include ('sphinxapi.php');
$cl = new SphinxClient();
$cl->SetServer( "SPHINX2", 3312 );
$cl->SetMatchMode( SPH_MATCH_EXTENDED);
$result = $cl->Query( "male","sphinx_search");
?>
The above returns male anywhere including the emp_notes field and emp_gender field. Please advice on how I can target columns. Will something like @emp_gender male work? It does not return results as expected
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用 字段搜索运算符,如下所示:
You have to use the field search operator like this:
性别等信息最好存储在属性中。
您可以将 SQL 查询更改为 smth。像这样:
然后您可以使用“性别”字段作为整数属性:
在您的应用程序中:
此解决方案的工作速度比按字段过滤要快得多,而且非常灵活,因为
过滤器和查询是分开的。
Such information as gender better to store in attributes.
Your could change your SQL query to smth. like this:
Then you may use 'gender' field as integer attribuite:
In your appp:
this solution would work much faster then filter by field and it is much flexible, because
filters and queries are separated.