我是做bulk inserts在RealTime Index使用PHP和禁用AUTOCOMIT,如
// sphinx connection
$sphinxql = mysqli_connect($sphinxql_host.':'.$sphinxql_port,'','');
//do some other time consuming work
//sphinx start transaction
mysqli_begin_transaction($sphinxql);
//do 50k updates or inserts
// Commit transaction
mysqli_commit($sphinxql);
Run Code Online (Sandbox Code Playgroud)
在我看到的早晨,让剧本一夜之间保持运行
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
212334 bytes) in
Run Code Online (Sandbox Code Playgroud)
所以当我仔细检查nohup.out文件时,我注意到,这些线条,
PHP Warning: mysqli_query(): MySQL server has gone away in /home/script.php on line 502
Warning: mysqli_query(): MySQL server has gone away in /home/script.php on line 502
Run Code Online (Sandbox Code Playgroud)
这些行之前的内存使用率是正常的,但这些行之后的内存使用量开始增加,并且它击中php mem_limit …
我正在开发项目,我需要用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);
Run Code Online (Sandbox Code Playgroud)
对于上面它工作正常,但是当我试图最小化响应时间查询表中的一个特定字段(使用扩展匹配模式,即SPH_MATCH_EXTENDED2),斯芬克斯只不过没有输出任何结果.我使用的扩展查询如下: -
$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);
Run Code Online (Sandbox Code Playgroud)
任何人都能认出我在哪里出错了吗?如果我在哪里错了,请帮忙.
提前致谢.
我在Heroku上运行Rails 3应用程序.我正在使用Thinking Sphinx搜索引擎进入我的应用程序.为了使它与Heroku一起工作,我flying-sphinx按照Heroku文档中的建议为我的gemfile 添加了一个gem.
这就是我在gemfile中的内容
gem 'thinking-sphinx', '2.0.11'
gem 'flying-sphinx', '0.7.0'
Run Code Online (Sandbox Code Playgroud)
根据这里提到的步骤https://devcenter.heroku.com/articles/flying_sphinx,添加了fly-sphinx插件(Heroku插件:添加flying_sphinx:木制)后,当我运行heroku运行fly-sphinx配置时出现以下错误:
/app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/sphinx_configuration.rb:2:in 'initialize': uninitialized constant FlyingSphinx::SphinxConfiguration::ThinkingSphinx (NameError)
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:31:in 'new'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:31:in 'configure'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:20:in 'block in run'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:20:in 'each'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:20:in 'all?'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/lib/flying_sphinx/cli.rb:20:in 'run'
from /app/vendor/bundle/ruby/1.9.1/gems/flying-sphinx-0.8.0/bin/flying-sphinx:5:in ''
from vendor/bundle/ruby/1.9.1/bin/flying-sphinx:19:in 'load'
from vendor/bundle/ruby/1.9.1/bin/flying-sphinx:19:in ''
我无法继续前进.
我正在试图找出如何通过匹配的标签数量来订购带有匹配标签的商品.
假设您有三个MySQL表:
tags(tag_id, title)articles(article_id, some_text)articles_tags(tag_id, article_id)现在让我们说你有四篇文章:
article_id = 1 有"幽默","搞笑"和"搞笑"的标签.
article_id = 2 有"滑稽","愚蠢"和"高飞"的标签.
article_id = 3 有"滑稽","愚蠢"和"高飞"的标签.
article_id = 4 标签"完全严重".
您需要找到article_id = 2至少一个匹配标记相关的所有文章,并按最佳匹配顺序返回结果.换句话说,article_id = 3应该先到article_id = 1第二,article_id = 4而不应该出现.
这是在SQL查询中单独使用的东西,还是更适合像Sphinx这样的东西?如果是前者,应该进行什么样的查询,以及应该为最高效的结果创建什么类型的索引?如果是后者,请进行扩展.
我在我的网站上搜索全文搜索到sphinx.我将使用SphinxSE来执行搜索.
我创建了2个索引,如手册中所述:http://www.sphinxsearch.com/docs/manual-0.9.9.html#live-updates
它似乎工作,并在其自己的索引中索引不同的东西,但我有点困惑我应该如何处理索引更新,合并和重建.
我理解的方式是我每隔5分钟左右运行"indexer delta --rotate",这会向索引添加新的提交.然后每天一次,我会通过运行"indexer main delta --rotate"将delta索引合并到主索引中.然后一个月左右,我将运行"indexer --all"来重建所有索引.
我这样做是对,还是我错过了什么?
我刚刚开始使用Sphinx.到目前为止,我已成功安装它,profiles在我的MySQL数据库索引上得到一个表,并且能够使用PHP API获得正确的结果.我正在使用CodeIgniter,所以我将默认的PHP API包装为CodeIgniter库.
无论如何这是我的代码的样子:
$query = $_GET['q'];
$this->load->library('sphinxclient');
$this->sphinxclient->setMatchMode(SPH_MATCH_ANY);
$result = $this->sphinxclient->query($query);
$to_fetch = array();
foreach($result['matches'] as $key => $match) {
array_push($to_fetch, $key);
}
Run Code Online (Sandbox Code Playgroud)
该数组$to_fetch包含匹配的表行的ID.现在我可以使用典型的MySQL查询来让所有相关用户在搜索页面上显示如下:
$query = 'SELECT * FROM profiles WHERE id IN('. join(',', $to_fetch) . ')';
Run Code Online (Sandbox Code Playgroud)
我的问题是:
这是正确的方法吗?或者是否存在默认的"Sphinx做法",这对性能会更好.
其次,我现在回来的是匹配的表行的id.我还想要匹配的列中的文本部分.例如,如果某人搜索该关键字,dog并且该profiles表上的用户在其about列中包含以下文本:
I like dogs. I also like ice cream.
我希望Sphinx能够回归:
I like <strong>dogs</strong>. I also like ice cream.
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我尝试使用该buildExcerpts()功能但无法使其工作.
这就是我现在摘录的方式:
// get matched user ids
$to_fetch = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种算法来按流行度对网站结果进行排序..就像Reddit那样,帖子越老,它的投票/得分就越少.
以下是reddit使用的普遍接受的解决方案:
t = (time of entry post) - (Dec 8, 2005)
x = upvotes - downvotes
y = {1 if x > 0, 0 if x = 0, -1 if x < 0)
z = {1 if x < 1, otherwise x}
rank = log(z) + (y * t)/45000
Run Code Online (Sandbox Code Playgroud)
我一直在使用Reddit的算法,虽然它适合一种情况,我真正需要的是两种算法,一种用于热门帖子,另一种用于即将发布的帖子:
流行的人会慢慢衰退,对于稍微偏旧的帖子会更加重要,其中即将发布的帖子今天将更多地关注热门帖子,在N小时/天/等之后大幅下降.
我正在使用Sphinx表达式写这个,所以我不能编写一个丑陋复杂的算法,我只能访问以下函数:
http://sphinxsearch.com/docs/current.html#numeric-functions
所以我每篇文章都有以下数据:
这是我目前的解决方案:
Exponent = 0.01 (Popular), 0.5 (Upcoming)
SecondsSincePublised = abs(CurTimeInSecondsSinceDate-PubTimeInSecondsSinceDate)
Rank = (log10(PostScore)*10000) / pow(SecondsSincePublised,Exponent)
Run Code Online (Sandbox Code Playgroud)
虽然这种解决方案的确起作用并不理想.在过去的几个小时内,一个新的和受欢迎的帖子在流行和即将到来时往往排名很高,这不是我想要的.
任何人都可以提出另一种算法,我可以修改指数成分来调整衰减吗?
我正在使用Thinking Sphinx进行全文搜索,关注此视频.
我想做以下事情:
@articles = Article.search(params[:search], :conditions => "published_at IS NOT NULL", :order => :created_at)
Run Code Online (Sandbox Code Playgroud)
问题是这不起作用.似乎搜索方法只接受哈希条件.我已经尝试了几种方法,但我对如何将"published_at IS NOT NULL"表示为哈希表示无能为力......
我正在使用Sphinx 0.9.9-release(r2117)和sphinxapi.php(http://code.google.com/p/sphinxsearch/source/browse/tags/REL_0_9_9_RC2/api/sphinxapi.php).
当我在命令shell中测试搜索时:"search -i INDEX_NAME test"一切都很完美,但当我通过sphinxapi.php连接到Sphinx时会发生此错误.
sphinx.conf配置正确,索引创建...
什么想法可能是错的?
我在weightSphinx 遇到了一个奇怪的问题.仅在执行全文时name,结果将被准确加权.但是当它通过搜索扩展时address,计算出的重量是不正确的.
我正在使用 Sphinx 2.2.11
示例1:搜索名称会产生正确的结果
$cl->SetRankingMode(SPH_RANK_SPH04);
$cl->SetSortMode(SPH_SORT_EXTENDED, '@weight desc');
$cl->SetMatchMode(SPH_MATCH_EXTENDED2);
$res = $cl->Query('@name ("la" | "comedie" | "saint" | "michel")', 'idx_name');
Run Code Online (Sandbox Code Playgroud)
产量
Venue Name Address Weight
La Comédie Saint-Michel boulevard Saint-Michel 19620
La Comédie Saint-Michel - Small Hall boulevard Saint-Michel 18649
La Comédie Saint-Michel - Grande Salle boulevard Saint-Michel 18649
Run Code Online (Sandbox Code Playgroud)
要匹配的单词
[words] => Array
(
[la] => Array
(
[docs] => 26110
[hits] => 29358
)
[comedie] => Array
(
[docs] => …Run Code Online (Sandbox Code Playgroud)