{
String servername = resultSet.getString("servername").toLowerCase();
String botname = resultSet.getString("botname").toLowerCase();
String channel = resultSet.getString("channel").substring(1).toLowerCase();
String key = getIndexName(botname, servername, channel);
Document doc = new Document();
Timestamp moment = resultSet.getTimestamp("moment");
IndexWriter writer = (IndexWriter)index_writer_cache.get(key);
if (writer == null)
{
writer = getIndexWriter(key, true);
index_writer_cache.put(key, writer);
}
beginningOfDay.setTime(moment);
beginningOfDay.setTimeZone(TimeZone.getTimeZone(DroneConfig.getTimezone()));
beginningOfDay.set(Calendar.HOUR, 0);
beginningOfDay.set(Calendar.MINUTE, 0);
beginningOfDay.set(Calendar.SECOND, 0);
beginningOfDay.set(Calendar.MILLISECOND, 0);
long dayInMillis = beginningOfDay.getTimeInMillis();
long timeInMillis = moment.getTime() - dayInMillis;
// need to store channel without the '#'
doc.add(new Field("moment", DateField.dateToString(resultSet.getTimestamp("moment")), true, true, true));
doc.add(new Field("momentDateSort", String.valueOf(dayInMillis), false, true, false));
doc.add(new Field("momentTimeSort", String.valueOf(timeInMillis), false, true, false));
doc.add(new Field("botname", botname, true, true, true));
doc.add(new Field("channel", channel, true, true, true));
doc.add(new Field("servername", servername, true, true, true));
doc.add(new Field("nickname", resultSet.getString("nickname"), true, true, true));
doc.add(new Field("username", resultSet.getString("username"), true, true, true));
doc.add(new Field("hostname", resultSet.getString("hostname"), true, true, true));
doc.add(new Field("message", resultSet.getString("message"), true, true, true));
try
{
writer.addDocument(doc, getAnalyzer());
}