让.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;
        }
posted @ 2005-10-25 22:48 Lyn 阅读(1686) 评论(2)  编辑 收藏 所属分类: ASP.net

  回复  引用  查看    
#1楼 2006-08-17 17:03 | 蛙蛙池塘      
.text如果部署到生产环境会自动支持abc.cnblogs.com这样的域名吗?还是每一个都要建立二级域名解析呀?有没有这方面的资料。
另外总结了几点,
xp建立映射的时候扩展名要用“.*”,不要“*.*”,而且映射的isapi不要复制要选择,选一下,然后点一下扩展名,然后再选,再点,才让你点确定。。
vs无法打开和创建Web项目除了添加不必要的*.*和aspnet_regiis的问题外,还有一种可能是.webinfo的问题
cndottext的winxp系列皮肤的xml图标有问题,在虚拟目录下显示不出来,需要修改control/CategoryList.ascx换成../Images/xml.gif
  回复  引用  查看    
#2楼 [楼主]2006-08-20 09:19 | THIN      
@蛙蛙池塘
.text如果部署到生产环境会自动支持abc.cnblogs.com这样的域名吗?
.Text本身不支持abc.cnblogs.com这样的域名,这样的域名都是我们自己开发加上去的功能。

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
"五向定位"职业成长路线公开课(上海、南京、大连)
Google站内搜索


相关链接: