throws IOException, ServletException {
response.setContentType("text/plain");
PrintWriter printWriter = response.getWriter();
ArrayList list = null;
Form article = null;
// - Retrieve collection of items in databse
// -- For larger collections, the results would have to
// -- batched in segments of, say, 100 records each
// - ResultUtils.getCollection is the underlying
// - actor here, and returns an ArrayList
try {
// - Create an indexWriter and start a fresh index
IndexWriter index = Engine.getIndexWriter(true);
// - Run through list and create a document for each article
// -- Store keyword and title since they are needed for the search list
// -- Be sure not to pass any blank strings
list = (ArrayList)
Access.select(new Form());
for (int i=0; i<list.size(); i++) {
article = (Form) list.get(i);
// - Add document to index
Access.index(
article.getArticle(),article.getContributor(),article.getCreator(),
article.getTitle(),article.getContent(),index);
// - Report progress
printWriter.print(i); printWriter.print(':');
printWriter.println(article.getTitle());
}
// - Final report
printWriter.print(index.docCount());
printWriter.println(" articles indexed.");