搜索部分带有教义的词

发布于 2024-11-28 03:06:56 字数 126 浏览 4 评论 0原文

我正在尝试使用 codeigniter 和原则执行全文搜索。 我的问题是 Doctrine 仅对整个单词执行搜索。

例如,我正在搜索“山”,我得到的每个条目都带有“山”一词。 但如果我搜索“mount”,我什么也得不到。

I am trying to perform fulltext search with codeigniter and doctrine.
My problem is that Doctrine perform the search only on wholes words.

For exemple, il I'am searching "mountain", I get every entry with the word mountain.
But If I'am searching "mount", I get nothing.

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

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

发布评论

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

评论(1

つ可否回来 2024-12-05 03:06:56

我在 Symfony 1.4 和 Doctrine 1.2 的可搜索行为中遇到了同样的问题,并遇到了这个问题。然后我发现您可以将通配符(?或*)添加到适用于单词的搜索词中。在你的情况下,“mount*”将匹配 mountain。就我而言,我将其应用于每个搜索词并向用户隐藏。

$results = $table->search('*'.$search_string.'*');

希望这对某人有帮助!

-- 编辑 --

上面有点仓促地发布了...这对于单个单词查询非常有效,但在多个部分单词上再次失败。像这样的东西应该效果更好:

$actual_search_string = '*'.implode('* *', explode(' ', $search_string)).'*';
$results = $table->search($actual_search_string);

I had the same problem with Symfony 1.4 and Doctrine 1.2 with the Searchable behaviour and came across this question. I then found you can add wildcards (? or *) to the search term which applies to the words. In your case "mount*" would match mountain. In my case I applied this to each search term and hid it from the user.

$results = $table->search('*'.$search_string.'*');

Hope this helps someone!

-- edit --

Posted a little hastily above... This works great for single word queries, but fails again on multiple partial words. Something like this should work better:

$actual_search_string = '*'.implode('* *', explode(' ', $search_string)).'*';
$results = $table->search($actual_search_string);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文