Sphinx 通配符搜索不起作用

发布于 2024-09-12 13:06:45 字数 1782 浏览 7 评论 0原文

我使用了以下代码:

   function searchSphinx2($tofind,$jobtype_id,$payper_id,$onetimeBounds)
    {
        $this->load->library('session');
        $this->load->library('sphinxclient');
        global $result;
        global $functionresult;
        $functionresult=array();

        $this->sphinxclient->setServer('localhost', 3312);
        $this->sphinxclient->SetMatchMode( SPH_MATCH_ANY );
        $this->sphinxclient->SetIndexWeights( array("jobs_index_main"=>10, "jobs_index_delta"=>10,"jobs_index_prefix_main"=>1,"jobs_index_prefix_delta"=>1,"jobs_index_infix_main"=>1,"jobs_index_infix_delta"=>1) );

        $this->sphinxclient->ResetFilters();
        $this->sphinxclient->SetFilter('jobtype_id',$jobtype_id,TRUE);
        $this->sphinxclient->SetFilter('payper_id',$payper_id,TRUE);
        $this->sphinxclient->SetFilterFloatRange('payamount', $ontimeBounds[0], $ontimeBounds[1], FALSE);

        $this->sphinxclient->AddQuery("$tofind", "jobs_index_main;jobs_index_delta");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_prefix;jobs_index_delta_prefix");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_infix;jobs_index_delta_infix");
        $result = $this->sphinxclient->RunQueries();

在我的数据库中有一个标题为“实习生”的职位但是,如果我搜索“inter”,我不会得到任何结果。

我的配置文件中的索引设置如下:

index jobs_index_prefix_main
{
        source  = jobs_main
        path = /var/newsphinx/index/main_prefix

        morphology = stem_en
        min_stemming_len = 4
        min_word_len = 3
        min_prefix_len = 3
        prefix_fields = title, contactname
        enable_star =1
}

谁能告诉我为什么我没有得到部分单词结果?

I have used the following code:

   function searchSphinx2($tofind,$jobtype_id,$payper_id,$onetimeBounds)
    {
        $this->load->library('session');
        $this->load->library('sphinxclient');
        global $result;
        global $functionresult;
        $functionresult=array();

        $this->sphinxclient->setServer('localhost', 3312);
        $this->sphinxclient->SetMatchMode( SPH_MATCH_ANY );
        $this->sphinxclient->SetIndexWeights( array("jobs_index_main"=>10, "jobs_index_delta"=>10,"jobs_index_prefix_main"=>1,"jobs_index_prefix_delta"=>1,"jobs_index_infix_main"=>1,"jobs_index_infix_delta"=>1) );

        $this->sphinxclient->ResetFilters();
        $this->sphinxclient->SetFilter('jobtype_id',$jobtype_id,TRUE);
        $this->sphinxclient->SetFilter('payper_id',$payper_id,TRUE);
        $this->sphinxclient->SetFilterFloatRange('payamount', $ontimeBounds[0], $ontimeBounds[1], FALSE);

        $this->sphinxclient->AddQuery("$tofind", "jobs_index_main;jobs_index_delta");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_prefix;jobs_index_delta_prefix");
        $this->sphinxclient->AddQuery("*$tofind*", "jobs_index_main_infix;jobs_index_delta_infix");
        $result = $this->sphinxclient->RunQueries();

In my data base there is a job with title "Intern" However, if I search for "inter" I do not get any results.

The indices in my confi file are set up as follows:

index jobs_index_prefix_main
{
        source  = jobs_main
        path = /var/newsphinx/index/main_prefix

        morphology = stem_en
        min_stemming_len = 4
        min_word_len = 3
        min_prefix_len = 3
        prefix_fields = title, contactname
        enable_star =1
}

Can anyone tell me why I am not getting partial word results?

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

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

发布评论

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

评论(1

再可℃爱ぅ一点好了 2024-09-19 13:06:45

我从未发现 Sphinx 在不使用星号的情况下返回部分匹配项。我同意这不是特别直观(当然,如果前缀被索引,就会有匹配项?),但如果您想确保始终获得结果,请在每个单词的末尾添加一个星号。

I've never found Sphinx to return partial matches without using stars. I agree that it's not particularly intuitive (surely if the prefixes are being indexed, there's a match?), but if you want to ensure you always get results, add a star to the end of each word.

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