Index only specific header keys for SEARCH

This commit is contained in:
Andris Reinman 2017-06-05 16:22:07 +03:00
parent a2488b6de4
commit ff633828be
3 changed files with 6 additions and 18 deletions

View file

@ -69,6 +69,7 @@ describe('IMAP Command Compiler', function() {
describe('ATOM', function() {
it('should compile correctly', function() {
parsed.attributes = [
//
{
type: 'ATOM',
value: 'ALERT'

View file

@ -22,7 +22,7 @@ const packageData = require('./package.json');
const BULK_BATCH_SIZE = 150;
// how often to clear expired messages
const GC_INTERVAL = 1 * 60 * 1000;
const GC_INTERVAL = 60 * 60 * 1000;
// Setup server
const serverOptions = {
@ -1970,7 +1970,7 @@ function clearExpiredMessages() {
clearTimeout(gcTimeout);
// First, acquire the lock. This prevents multiple connected clients for deleting the same messages
gcLock.acquireLock('gc_expired', 10 * 60 * 1000 /* Lock expires after 10min if not released */, (err, lock) => {
gcLock.acquireLock('gc_expired', 61 * 60 * 1000 /* Lock expires after 61min if not released */, (err, lock) => {
if (err) {
server.logger.error(
{

View file

@ -14,21 +14,8 @@ const counters = require('./counters');
const BULK_BATCH_SIZE = 150;
const SCHEMA_VERSION = '1.0';
// header prefixes that are skipped when building index
const IGNORE_HEADERS = [
'arc-',
'authentication-',
'content-',
'dkim-',
'list-',
'mime-',
'received',
'x-gm-',
'x-google-',
'x-original-',
'x-originating-',
'x-received'
];
// index only the following headers for SEARCH
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index'];
class MessageHandler {
constructor(database, redisConfig) {
@ -726,7 +713,7 @@ class MessageHandler {
let key = line.substr(0, line.indexOf(':')).trim().toLowerCase();
if (IGNORE_HEADERS.find(prefix => key.indexOf(prefix) === 0)) {
if (!INDEXED_HEADERS.includes(key)) {
// do not index this header
return false;
}