config.setOpenMode(IndexWriterConfig.OpenMode.CREATE); // Overwrite existing.
IndexWriter writer = new IndexWriter(FSDirectory.open(indexLocation), config);
int cnt = 0;
Status status;
try {
while ((status = stream.next()) != null) {
if (status.getText() == null) {
continue;
}
cnt++;
String createdAt = status.getCreatedAt();
Document doc = new Document();
doc.add(new Field(StatusField.ID.name, status.getId() + "",
Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field(StatusField.SCREEN_NAME.name, status.getScreenname(),
Store.YES, Index.NOT_ANALYZED_NO_NORMS));
doc.add(new Field(StatusField.CREATED_AT.name, createdAt, Store.YES, Index.NO));
doc.add(new Field(StatusField.TEXT.name, status.getText(), Store.YES, Index.ANALYZED));
String[] arr = createdAt.split(" ");
String createDay = new StringBuffer().append(arr[1]).append("_").append(arr[2]).toString();
doc.add(new Field(StatusField.DAY.name, createDay, Store.YES, Index.NOT_ANALYZED_NO_NORMS));