资 源 简 介
Introduction
Run Lucene in App Engine.
Example: http://lucene-gae-example.appspot.com/
Index
Index texts in Lucene just like in the FileSystem Directory.
```
public class IndexServlet extends HttpServlet {
private static final Version VERSION = Version.LUCENE_34;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String text = req.getParameter("text");
DataStoreDirectory directory = new DataStoreDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(VERSION, new StandardAnalyzer(VERSION));
iwc.setMergeScheduler(new SerialMergeScheduler());
IndexWriter writer = new IndexWriter(directory, iwc);
Document doc = new Document();
doc.add(new Field("text", text, Field.Store.YES, Field.Index.ANALYZED));
writer.addDocument(doc);
writer.close();
}
}
```
Search