This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » Search plugins » How to count several items with sfLucene!
How to count several items with sfLucene! [message #70459] Thu, 22 January 2009 08:18 Go to next message
wgbbiao  is currently offline wgbbiao
Messages: 14
Registered: September 2007
Junior Member
我可做一个像淘一样的搜索吗?用sfLucene!


Can I make a web like www.taobao.com with sfLucene!

[Mod: renamed post - halfer]

[Updated on: Fri, 23 January 2009 12:23] by Moderator

Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #70468 is a reply to message #70459 ] Thu, 22 January 2009 10:28 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
Probably. What functionality is it that you want to replicate? sfLucene will give you a complex search facility, which you can interrogate using the default search page, or you can create your own. The best thing here is to give it a go, and drop a line here if you run into problem. Don't forget to search the fora first though, as many common questions have already been asked.


Remember Palestine
Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #70555 is a reply to message #70468 ] Fri, 23 January 2009 03:13 Go to previous messageGo to next message
wgbbiao  is currently offline wgbbiao
Messages: 14
Registered: September 2007
Junior Member
I want to get the number

  • Attachment: 无标题.jpg
    (Size: 32.72KB, Downloaded 291 time(s))

Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #70570 is a reply to message #70459 ] Fri, 23 January 2009 12:22 Go to previous messageGo to next message
halfer  is currently offline halfer
Messages: 9535
Registered: January 2006
Location: West Midlands, UK
Faithful Member
I can't read the text on that image, but it looks like they are categories of some kind. My guess is that this would be done with a database, not Lucene. Counting Lucene searches ten or 15 times in a single page would be, to my mind, far too slow.

Perhaps if you can indicate the nature of the "counted things" on that page, someone could give you a more accurate answer?


Remember Palestine
Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #71214 is a reply to message #70570 ] Mon, 02 February 2009 03:47 Go to previous messageGo to next message
wgbbiao  is currently offline wgbbiao
Messages: 14
Registered: September 2007
Junior Member
4.计算catetries 的数量;
plugins/sfLucenePlugin/lib/vendor/Zend/Search/Lucene.php
在797 行添加:
$catetries = array();//初始化数组


foreach ($query->matchedDocs() as $id => $num) {
$docScore = $query->score($id, $this);
if( $docScore != 0 ) {
$hit = new Zend_Search_Lucene_Search_QueryHit($this);
$hit->id = $id;
$hit->score = $docScore;
$hits[] = $hit;
$ids[] = $id;
$scores[] = $docScore;

if ($docScore > $topScore) {
$topScore = $docScore;
}
}

if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) {
break;
}
}
将此段代码改为:
foreach ($query->matchedDocs() as $id => $num) {
$docScore = $query->score($id, $this);
if( $docScore != 0 ) {
$hit = new Zend_Search_Lucene_Search_QueryHit($this);
$hit->id = $id;
$hit->score = $docScore;
//添加此段代码 开始
foreach (explode(',' , $hit->sfl_category) as $category)
{
$category = trim($category);
if (isset($catetries[$category])) {
$catetries[$category] ++;
}
else
{
$catetries[$category] = 1;
}
}
//添加此段代码 结束
$hits[] = $hit;
$ids[] = $id;
$scores[] = $docScore;

if ($docScore > $topScore) {
$topScore = $docScore;
}
}

if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) {
break;
}
}

在函数结束时添加:
$hits['catetries'] = $catetries; //添加此行
return $hits;


plugins/sfLucenePlugin/lib/results/sfLucenePager.class.php
添加函数:
public function getCatetries()
{
return $this->results['catetries'];
}

调用$pager->getCatetries() ($pager 为sfLucenePager 对象 ) 可得行类似:Array ( [saving] => 1 [search] => 1 [financing] => 1 [pursueFinacing] => 1 [compare] => 1 [gradeSearch] => 1 [searchOld] => 1 [searchcredit] => 1 [simpleSerarch] => 1 [select] => 1 [installment] => 1 [otherloans] => 1 [auto] => 1 [accredit] => 1 [otherinvestment] => 1 [fundfilter] => 1 [remit] => 1 [index] => 1 [foreign] => 1 [homeloan] => 1 [howLoan1] => 1 [common] => 1 [allBankHomeLoan] => 1 [assigendShop] => 1 [calc] => 1 [repaymentComparison] => 1 [lateRepayment] => 1 [installments] => 1 [DCwithdrawalsFee] => 1 [excessFee] => 1 [CCwithdrawalsFee] => 1 [overLimitFee] => 1 [latePayments] => 1 [onlineTransferFee] => 1 [transfersFee] => 1 [savingInt] => 1 [nationaldebt] => 1 [bankDebt] => 1 [result] => 1 [managementFees] => 1 [auditing] => 1 [searchOldFc] => 1 ) 的数组.



注:最后的数据会多一个 应该相应的减1

I did it like this!
Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #71292 is a reply to message #71214 ] Tue, 03 February 2009 03:55 Go to previous messageGo to next message
wgbbiao  is currently offline wgbbiao
Messages: 14
Registered: September 2007
Junior Member
添加上段代码后,速度提升了很多!

[Updated on: Thu, 17 December 2009 03:52]

Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #76556 is a reply to message #71292 ] Thu, 09 April 2009 05:57 Go to previous messageGo to next message
assassinann  is currently offline assassinann
Messages: 28
Registered: February 2009
Location: china
Junior Member

首先您很有性格啊···在英文论坛里面发中文 贴···哈哈··
我就不用英文请教您了啊··
现在我到一个问题想请教您一下·
我按照jobeet中的search那一章做了一个搜索栏
但是搜索中文的时候搜索不到结果啊·?
我使用的数据库是MySQL,建立数据库时使用的编 码是utf8_bin,在建立索引文件文件时在索引文 中存储的应该也是utf8的
(语句:$doc->addField(Zend_Search_Lucene_Field::UnStored(’name’, $this->getName(), ‘utf-8′))),
请问这个问题怎么解决呢·?盼回复···谢谢 ···

[Updated on: Thu, 09 April 2009 05:59]

Re: 我可做一个像淘一样的搜索吗?用sfLucene! [message #90124 is a reply to message #76556 ] Thu, 17 December 2009 03:58 Go to previous message
wgbbiao  is currently offline wgbbiao
Messages: 14
Registered: September 2007
Junior Member
好像不看了。。
不知道你的问题解决了没有。
只要设置了编码,应该没有什么问题。


我现在遇到了一个问题:
现在索引文件很大了,400多M,搜一个词用OR的 关系去搜时就会很慢。20秒以上吧。。
相当烦人。


你有什么好招吗?
Previous Topic:Searchable + Blog index
Next Topic:sfSocialPlugin Problem in index.php
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software