我在Sphinx中有索引。索引中的一个字段是URL。它包含例如下一个值:
(1) http://u24.ru/news/38417/v-centre-chelyabinska-muzhchina-popytalsya-pereplyt-reku?rss
(2) https://meduza.io/feature/2017/07/10/islamskoe-gosudarstvo-vybili-iz-mosula-chto-budet-dalshe
(3) https://stolica-s.su/sport/athletics/89078
我如何尝试按网址搜索(部分代码):
$query = $this->manager->makeQuery()
->select(['id'])
->from(['content']);
$url = str_replace(
['=', '&', '?', '-', '%'],
[' ', ' ', ' ', ' ', ' '],
'http://www.ruscur.ru/themes/0/00/70/7020.shtml?news/0/10/43/104359'
);
$url = $query->escapeMatch($url);
$query->match('url', $url);
var_dump($query->execute()->fetchAllAssoc()); // empty
有没有办法在不使用全文搜索的情况下搜索Sphinx?
答案 0 :(得分:1)
您可以创建URL的哈希并存储它,然后通过哈希进行比较:
$query = $this->manager->makeQuery()
->select(['id'])
->from(['content'])
->where('hash', '=', Hasher::hash($url));