本模块目前只提供数据库搜索,暂不支持静态页面搜索。
这部分包括9部分:
CommunityComponents.IJob 提供从Xml节点执行方法的接口。
Search 提供搜索引擎。
.CommunityComponents.SearchJob 提供查询任务。
CommunityComponents.SearchQuery 提供查询条件。
CommunityComponents.Word 提供查询词的定义。
WordLocation 提供查询词所处位置。
CommunityComponents.PostSet 提供帖子以及回复集合。
CommunityComponents.SearchResultSet 提供查询集合。
1.1 执行任务接口
void Execute(XmlNode node);定义所有执行任务执行此方法,并传入XML节点数据。
1.2 提供搜索引擎
抽象方法:
abstract void IndexPosts (int setSize, int settingsID);执行对帖子建立索引。
abstract double CalculateWordRank (Word word, Post post, int totalBodyWords);
计算此词的排名。
abstract SearchResultSet GetSearchResults (SearchQuery query, SearchTerms terms);
获取查询结果集合
abstract ArrayList GetPermissionFilterList();获取权限过滤列表。
virtual SearchResultSet GetSearchResults(SearchQuery query)根据传入查询,指定SectionsToFilter为GetPermissionFilterList(),并调用分词方法GetSearchTerms(),返回查询结果集合。
InsertIntoSearchBarrel(Hashtable words, Post post, int settingsID, int totalBodyWords),将此词的排名进行计算,并插入数据库。
static Hashtable GetIgnoreWords (int settingsID):提供该配置下的所有过滤词,并进行缓存。
static string[] CleanSearchTerms(string searchTerms):移除传入查询条件中的所有非法字符,并返回干净字符串数组。
static Hashtable Index (string contentToIndex, Hashtable words, WordLocation wordLocation, int settingsID)对建立索引的内容contentToIndex执行方法CleanSearchTerms,通过词的散列编码与过滤词的散列编码比较,如果不同,则判断是否传入词表words是否已包含该词,来觉得累加还是新建词。
1.3 提供查询任务
用于后台线程为当前查询下的帖子执行索引服务,此执行方法执行接口Ijob。
1.4 提供查询条件
GroupToSearch:组过滤,SectionsToSearch:章节过滤,UsersToSearch:用户过滤,SectionsToFilter:章节过滤条件,SearchTerms:查询分词。PageIndex:定义取那页,PageSize:定义每页大小。
static SearchQuery FirstPageQuery(string textToFind)定义第一次查询方法,textToFind为查询条件SearchTerms。
static SearchQuery SectionSearch(string textToFind, int SectionID)定义从那一章节条件为textToFind的查询。
1.5 提供查询连接词
string[] And:定义所有And连接的条件,string[] Or:定义所有OR连接的条件。
HasTerms:判断此查询是否存在And或者Or的条件。
1.6 提供查询词的定义
对于检索词的定义
Occurrence 出现频率,word 此词名称,_occurenceWeight此词权重,权重根据此词所处位置划分了不同的比例因子。
1.7 提供查询词所处位置
此枚举目前提供如下位置:
Section:章节,Excerpt:摘要(简要说明处),Subject:标题,Body:正文,Author:作者。
1.8 提供帖子以及回复集合
Posts:所有的帖子集合(发贴和回帖总数), Replies:所有的回帖,ThreadStarter:当前发贴Post。
bool HasResults:是否存在帖子。
int TotalRecords:总共记录数。
1.9 提供查询集合
继承PostSet,并提供查询所耗用的时间精确到毫秒SearchDuration。