[英]Search results with Sphinx and PHP by partial string
我正在尝试Sphinx入门。 我将一些结果添加到索引,下载sphinxapi.php
,然后执行以下操作:
$cl = new SphinxClient();
$cl->SetServer( "localhost", 9312 );
// SPH_MATCH_ALL will match all words in the search term
$cl->SetMatchMode(SPH_MATCH_ALL);
$result = $cl->Query("test");
我得到这个( id = 5
行,其中title = test
):
array (size=1)
5 => // id of post in database
array (size=2)
'weight' => string '2' (length=1)
'attrs' =>
array (size=0)
empty
但是,为什么我没有从id = 6
数据库中获取行,其中title
字段等于test1
呢?
和$cl->SetMatchMode(SPH_MATCH_ALL);
火灾错误:
DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API
我在api文件的代码中注释了这一行:
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
但是我不知道是否可以。 有人可以帮助我了解我在做什么错吗? 谢谢!
要获得“子字符串”匹配项,您需要专门启用它们。
http://sphinxsearch.com/docs/current.html#conf-min-prefix-len
(或min_infix_len)
如果您不想看到折旧的通知,请设置error_reporting http://php.net/manual/en/function.error-reporting.php
(但更好的方法是重写代码以避免调用已贬值的方法)
警告设置匹配模式
SetMatchMode已弃用,您仍然可以使用它,但是可以在下一版本中将其删除。
有关它的更多信息,请参见:
从狮身人面像论坛(barryhunter)摘录:
更改“匹配模式”实际上做了两件事,它通过重写查询本身来更改了匹配>行为。 并且更改排名模式。
通过解耦这些概念,我想这是在减少混乱。
(例如,一旦您选择其他匹配模式,就不能>强制选择排名模式)
...匹配模式是在“扩展语法”被完全开发之前提出的,但是现在一切都可以通过扩展语法直接完成。
关于搜索结果
barryhunter答案是正确的
我建议阅读更多有关字符集表,形态和词干的信息,因为与通配符搜索相比,我认为这是实现成功搜索的更好方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.