与 Cake php 一起实现 Sphinx API 的问题

发布于 2024-11-09 00:15:08 字数 1035 浏览 2 评论 0原文

我正在开发一个项目,需要使用 Cake php 实现 SphinxSearch。所以我只是尝试在其中使用一个组件和行为。它的链接是:-

http:// /bakery.cakephp.org/articles/eugenioclrc/2010/07/10/sphinx-component-and-behavior

我正在请求 Sphinx API,如下所示:

$sphinx = array('matchMode' => SPH_MATCH_ALL, 'sortMode' => array(SPH_SORT_EXTENDED => '@relevance DESC'));

$results = $this->ModelName->find('all', array('search' => 'Search_Query', 'sphinx' => $sphinx));

pr($result);

对于上面的内容,它工作正常,但是当我尝试最小化响应时间查询表的特定字段(使用扩展匹配模式,即SPH_MATCH_EXTENDED2),Sphinx无法输出任何结果。我使用的扩展查询如下:-

$sphinx = array('matchMode' => SPH_MATCH_EXTENDED2, 'sortMode' => array(SPH_SORT_EXTENDED => '@relevance DESC'));

$results = $this->ModelName->find('all', array('search' => '@Field_name Search_Query', 'sphinx' => $sphinx));

pr($results);

任何人都可以认识到我哪里出了问题吗?如果我在某些地方出错,请帮助。

提前致谢。

I am working on project where I need to implement SphinxSearch with Cake php. So I am simply trying to use a component and behaviour into it. The link to it, is :-

http://bakery.cakephp.org/articles/eugenioclrc/2010/07/10/sphinx-component-and-behavior

I am requesting Sphinx API like below :

$sphinx = array('matchMode' => SPH_MATCH_ALL, 'sortMode' => array(SPH_SORT_EXTENDED => '@relevance DESC'));

$results = $this->ModelName->find('all', array('search' => 'Search_Query', 'sphinx' => $sphinx));

pr($result);

For above it is working fine ,but when I tried to minimise the response time querying to a particular field of the table (using extended match modes,i.e. SPH_MATCH_EXTENDED2) , Sphinx just fails to output any result. The extended query which I used is given below :-

$sphinx = array('matchMode' => SPH_MATCH_EXTENDED2, 'sortMode' => array(SPH_SORT_EXTENDED => '@relevance DESC'));

$results = $this->ModelName->find('all', array('search' => '@Field_name Search_Query', 'sphinx' => $sphinx));

pr($results);

Can anyone recognise where am I going wrong with it? Please help if I am going wrong some where.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

善良天后 2024-11-16 00:15:08

顺便说一句,当您使用 EXTENDED2 模式时,请确保您的排名模式已相应设置。

编辑

无论如何,回到你的问题,查看该组件/行为代码,你可以立即看到没有进行任何错误检查。尝试稍微更改一下代码,这样您至少可以看到错误和/或警告。

组件

if(!isset($query['search'])){ 
  $result = self::$sphinx->Query('', $indexes);     
} else { 
  $result = self::$sphinx->Query($query['search'], $indexes); 
}

if ($result === false) {
  // throw new SphinxException();
  die(self::$sphinx->GetLastError());
}
$warn = self::$sphinx->GetLastWarning();
if ($warn) echo $warn;

行为

$result=$this->runtime[$model->alias]['sphinx']->search($s);
if ($result === false) {
  die($this->runtime[$model->alias]['sphinx']->GetLastError());
}
$warn = $this->runtime[$model->alias]['sphinx']->GetLastWarning();
if ($warn) echo $warn;

我希望有所帮助。

Btw, when you use EXTENDED2 mode make sure your rank mode is set accordingly.

Edit:

Anyway back to you problem, looking at that component/behavior code you can see right away that no error checking is done whatsoever. Try changing the code a bit so you can at least see the errors and/or warnings.

Component

if(!isset($query['search'])){ 
  $result = self::$sphinx->Query('', $indexes);     
} else { 
  $result = self::$sphinx->Query($query['search'], $indexes); 
}

if ($result === false) {
  // throw new SphinxException();
  die(self::$sphinx->GetLastError());
}
$warn = self::$sphinx->GetLastWarning();
if ($warn) echo $warn;

Behavior

$result=$this->runtime[$model->alias]['sphinx']->search($s);
if ($result === false) {
  die($this->runtime[$model->alias]['sphinx']->GetLastError());
}
$warn = $this->runtime[$model->alias]['sphinx']->GetLastWarning();
if ($warn) echo $warn;

I hope that helps.

疧_╮線 2024-11-16 00:15:08

正如你所说,

Sphinx 无法输出任何结果。

这意味着这是一个错误:

请检查您是否已使用 sql_query 将特定字段添加到索引中,

同时检查您正在搜索的字段是否不是属性
根据 sphinx 文档:

与字段不同,属性没有全文索引。它们存储在索引中,但无法对它们进行全文搜索,并且尝试这样做会导致错误。

As you said ,

Sphinx just fails to output any result.

That means it's an error :

Please check whether you have added the specific field to the indexing by using sql_query

Also check if the field you are searching for is not an attribute
As per the sphinx documentation :

Attributes, unlike the fields, are not full-text indexed. They are stored in the index, but it is not possible to search them as full-text, and attempting to do so results in an error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文