如何落伍 | 站长实名俱乐部 | 站长知道 | 落伍预告 | 落伍分类 | 站长运营 | 赚钱 | 代码 | 现金任务 | 招聘 | 交易 | 落伍DIY | 帐号保护
推荐:图铃+艺术签名效果强!墨者推出江民杀毒,5元一个,效果好美图:20元1000IP、周付佣金反馈提成活动ACS金玉满堂
天寻网络租用699/月 空间30元/月域名1元 空间10元 酷睿租用699起炎黄网络:P4月付399元 送8G硬防赚钱:Q号+艺术签名效果超强!
挚盟广告联盟,收入满100送100英拓酷睿租用598/月,5199/年比VPS更稳定的VM虚拟服务器P4 3.0/1G/160G/10M独享-550元
DNSPod智能DNS,我们一直在免费莆阳:E4500/2G季付1999元送产权雅唐空间100元.南京双线租用699元独享百兆托管9000/年,租1399/月
发新话题
打印

[站长技术] (sina)让.Text的搜索引擎支持二级域名

(sina)让.Text的搜索引擎支持二级域名

  最近在做.Text Blog的Wap版,因为手机上输入比电脑上更难,所以,如果用户手动输入地址访问Blog的话,会对没有意义又繁长的URL非常反感,所以,花了点时间做了.Text对二级域名的支持并对其地址分析功能做了些优化,可是做好后发现,.Text的搜索引擎并不支持这种域名方式,没办法,只好对它的搜索引索又动了点小手术。(博客园现在有点慢啊)

  1、对Web.config的修改:
 
<SearchConfiguration type="Dottext.Search.SearchConfiguration, Dottext.Search" urlFormat="http://{1}{0}/Blog/{2}/{3}.aspx"
        virtualPath
="~/SearchIndex" physicalPath="D:\Code\MSS1\Blog\DotTextWeb\SearchIndex" domains=".tzl.com"
        pageSize
="20"
/>


其中http://{1}{0}/Blog/{2}/{3}.aspx中的Blog是你的应用程序名,比如你的程序在www.blog.com/blog下,注意domains不要加上www之类的

  2、将Dottext.Search.EntryData类的CreateDoc(IDataReader reader)方法改成这样


private Document CreateDoc(IDataReader reader)
        
{
            
//Null values are not allowed in the index
            
            Document doc
=
new Document();
            
try
            
{
                doc.Add(Field.Text(SearchConfiguration.Author,(
string)reader["Author"]));

                doc.Add(Field.Text(SearchConfiguration.Title,(
string)reader["Title"]));

               
string body = (string)reader["Text"];
                doc.Add(Field.UnIndexed(SearchConfiguration.Body,body));
                doc.Add(Field.Text(SearchConfiguration.Link,
string.Join("
",GetLinks(body))));
                doc.Add(Field.Text(SearchConfiguration.RawPost,regexStripHTML.Replace(body,
string.Empty)));

                DateTime dateCreated
= (DateTime)reader["DateAdded"];
                doc.Add(Field.UnIndexed(SearchConfiguration.DateCreated,dateCreated.ToLongDateString()));

               
string app = (string)reader["Application"];
                doc.Add(Field.Text(SearchConfiguration.Blog,app));

               
//Do we really need this?
               
//doc.Add(Field.Text(SearchConfiguration.Description,reader["Description"].ToString()));

               
string host = (string)reader["Host"];
                doc.Add(Field.Text(SearchConfiguration.Domain,host));


               
int posttype = (int)reader["PostType"];        
                doc.Add(Field.UnIndexed(SearchConfiguration.PostType,posttype.ToString()));

               
string permaLink  =
null;
                SearchConfiguration searchConfig
= SearchConfiguration.Instance();
               
if((PostType)posttype == PostType.BlogPost)
               
{
                    
//permaLink = string.Format(SearchConfiguration.Instance().UrlFormat,host,app, "archive/" + dateCreated.ToString("yyyy'/'MM'/'dd"),reader["EntryID"]);
                    permaLink =
string.Format(searchConfig.UrlFormat,searchConfig.Domains,app, "archive/"
+ dateCreated.ToString("yyyy'/'MM'/'dd"),reader["EntryID"]);
                }

               
else
if((PostType)posttype == PostType.Comment)
               
{
                    permaLink
=    reader["SourceUrl"].ToString()+"#"+reader["EntryID"].ToString();
                }

               
else
               
{
                    
//permaLink = string.Format(SearchConfiguration.Instance().UrlFormat,host,app, "articles",reader["EntryID"]);
                    permaLink =
string.Format(searchConfig.UrlFormat,searchConfig.Domains,app, "articles",reader["EntryID"]);
                }


               
int feedbackCount = (int)reader["FeedbackCount"];
               
int webviewCount = (int)reader["WebViewCount"];

               
int boost = weighter.Calculate(body.Length,feedbackCount,webviewCount,dateCreated,(PostType)posttype);
                doc.SetBoost(boost);

                doc.Add(Field.UnIndexed(SearchConfiguration.BoostFactor,boost.ToString()));

                doc.Add(Field.UnIndexed(SearchConfiguration.PermaLink,permaLink));
            }

            
catch(Exception e)
            
{
                Dottext.Framework.Logger.LogManager.Log(
"CreateDoc Fail","EntryID is "+reader["EntryID"]);
            }

            
            
return doc;
        }


 来源:http://tech.sina.com.cn/s/s/2008-05-16/0911662968.shtml

TOP

TOP

没学会啊

TOP

nan

TOP

再仔细看一遍

TOP

发新话题