📄 user story - searchthreads.txt
字号:
Story:
User can search threads by title, content or a certain user
description:
.index creation (update index every one day)
if no index is created before (first time)
create new index for all threads in db
if index has been created append new thread to index
get the time the index was last modified. (IndexReader.lastModified("index"))
get all threads posted later than this time
(mysql> select title, timestamp from threads where timestamp>1051408066640;)
append these threads to index
.search interface:
search thread by title
search thread by content
not implemented:
search someuser's thread (first posted by a certain user)
(user can select to search one or all forum)
Usage:
1.first use "ant index" to build the index
the index dir is at TOMCAT_HOME/webapps/forum/threadindex
2.sometime every day, use "ant index" to append newly posted threads to index
CRC Card
-----------------------------------------------
IndexBuilder
------------------------------------
buildIndex(Collection threads)
appendIndex(Collection threads)
isIndexExist()
lastedModified()
createDocument(Thread thread)
main
ThreadSearcher
------------------------------------
findByTitle(title, forumId) (搜索某个论坛的标题)
findByContent(content, forumId) (搜索某个论坛的内容)
findByTitle(title) (搜索所有论坛的标题)
findByContent(content) (搜索所有论坛的内容)
findById(id) (搜索某个帖子)
Thread
------------------------------------
title
content
author
timestamp
category
categoryID
parentID
ThreadDAO
------------------------------------
findThreadsPostedLaterThan(time)
-----------------------------------------------
working items:
ok.ThreadDAO
.向 ThreadDAO 增加一个接口:findThreadsPostedLaterThan(time)
.向 ThreadDAOmySql 增加一个方法:findThreadsPostedLaterThan(time) 并测试之
ok.write Thread
ok.IndexBuilder
.createDocument(Thread thread)
.write isIndexExist()
.lastedModified()
.write buildIndex()
.write appendIndex()
.modify build.xml add target index
.test
.ThreadSearcher
.write findByTitle(title, forumId)
.write findByTitle(title)
.write findByContent(content, forumId)
.write findByContent(content)
.写页面
.写 jsp/findthreads.jsp (框架)
.写 jsp/content/findthreadsContent.jsp (三种搜索方法,且可选择某个或所有论坛)
.写 FindThreadForm
.写 FindThreadAction
.写 jsp/viewresults.jsp (框架)
.写 jsp/content/viewResultsContent.jsp
.在 /jsp/content/viewForumContent.jsp, jsp/content/forumListContent.jsp
添加“搜索帖子”链接
.修改 struts-config.xml
增加一个 action :findThread
增加一个 form-bean FindThreadForm
action findThread:
<action path="/findThread"
name="FindThreadForm"
input="/findthreads.jsp"
type="org.redsoft.forum.web.FindThreadAction"
validate="true">
<forward name="logon" path="/logon.jsp"/>
<forward name="success" path="/findresults.jsp"/>
<forward name="error" path="/error.jsp"/>
</action>
form-bean:
<form-bean name="FindThreadForm" type="org.redsoft.forum.web.FindThreadForm"/>
问题:
是否登陆的用户才能搜索帖子
how about thread modified after it is added to index
wish list:
automatic appeding newly posted threads to index. :)
在 viewForumContent.jsp 点击链接到 findThread.jsp 时选择某个 forum
比如: findThread.jsp?forum=1 后
findThread 的 Form 里 forum 下拉框选择了 第一个 forum
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -