cakephp 中 Sphinx 中的多重查询

发布于 2024-12-18 20:06:55 字数 437 浏览 0 评论 0原文

$query = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~100';
$query2 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~300'
$query3 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/3';
$query4 = '@(name,email,biot) ' . '"' . $this->passedArgs['name'] . '"/1';

我想在一个查询中执行此操作!如果我使用“|” OR运算符,大约需要2分钟才能显示结果!

无论如何,在 sphinxapi 中使用多重查询我可以将所有这些查询合并为一个吗?

$query = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~100';
$query2 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~300'
$query3 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/3';
$query4 = '@(name,email,biot) ' . '"' . $this->passedArgs['name'] . '"/1';

I want to execute this in one query! If I use the "|" OR operator, it takes approx 2minutes to display the results!

Is there anyway using multiquery in sphinxapi I can combine all these queries into one?

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

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

发布评论

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

评论(3

南烟 2024-12-25 20:06:55

你可以试试

@(name,email,bio) ( "one two"~100 | "one two"~300 | "one two"/3 | "one two"/1 )

,可能会快一点。

You could try

@(name,email,bio) ( "one two"~100 | "one two"~300 | "one two"/3 | "one two"/1 )

Might be a bit quicker.

隐诗 2024-12-25 20:06:55

如果我理解(从您的评论中),您正在寻找 @(name,email,bio) 字段中的 $this->passedArgs['name']~100 个字符内OR ~300 个字符OR 至少有 /3至少匹配 OR 的单词/1 单词匹配?

为什么不将其分成两个不同的查询,首先是最受限制的:

$query = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~100';
$query4 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/1';

一起执行这些查询。如果您没有得到任何结果,请执行以下查询,也将|放在一起。

$query2 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~300'
$query3 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/3';

If I understand (from your comment), you're looking for $this->passedArgs['name'] in the @(name,email,bio) fields, within ~100 characters OR ~300 characters OR having at least /3 words matching OR at least /1 word matching?

Why not then split it out to two different queries, the most limiting first:

$query = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~100';
$query4 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/1';

perform those queries, |d together. If you get no results from it, perform the below query, also |d together.

$query2 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"~300'
$query3 = '@(name,email,bio) ' . '"' . $this->passedArgs['name'] . '"/3';
情仇皆在手 2024-12-25 20:06:55

我尝试使用 OR(|) 运算符进行单个查询,Sphinx 没有返回准确的结果。后来发现 AddQuery 函数可以帮助我从多个查询中获取结果并将其合并为一个。

我什至可以为每个查询指定单独的索引。请参阅 Sphinx 文档 AddQuery

    $cl->AddQuery('@(name,email,bio) "one two" ~100', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~300', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~300', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" /3', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~/1', 'metaphone dist'); 
    $result = $cl->RunQueries();
    echo "<pre>",print_r($result),"</pre>";

我执行了 SetIndexWeights 调用来优先考虑我拥有的多个索引用过的。请参阅 Sphinx 文档 SetIndexWeights

I tried the single query using OR(|) operator, Sphinx wasn't returning accurate results. Later found out AddQuery function which helped me in getting results from multiple queries and merging into one.

I can even specify separate indexes for each query. Refer Sphinx Documentation AddQuery

    $cl->AddQuery('@(name,email,bio) "one two" ~100', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~300', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~300', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" /3', 'dist'); 
    $cl->AddQuery('@(name,email,bio) "one two" ~/1', 'metaphone dist'); 
    $result = $cl->RunQueries();
    echo "<pre>",print_r($result),"</pre>";

I did SetIndexWeights call to prioritize multiple indexes that I have used. Refer Sphinx Document SetIndexWeights

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