Don't buffer all threads and messages in memory before indexing to elasticsearch
Don't buffer all threads and messages in memory before indexing to elasticsearch

Currently, the backfill search script will put all messages/threads into memory before flushing to elasticsearch. This could cause the host to OOM due to large accounts. This commit introduces a INDEX_CHUNK_SIZE which will flush to elasticsearch and remove the messages/threads from memory after INDEX_CHUNK_SIZE objects

ErinCall/sync-engine,nylas/sync-engine,wakermahmud/sync-engine,jobscore/sync-engine,Eagles2F/sync-engine,gale320/sync-engine,ErinCall/sync-engine,ErinCall/sync-engine,jobscore/sync-engine,ErinCall/sync-engine,closeio/nylas,closeio/nylas,wakermahmud/sync-engine,gale320/sync-engine,wakermahmud/sync-engine,gale320/sync-engine,Eagles2F/sync-engine,ErinCall/sync-engine,Eagles2F/sync-engine,Eagles2F/sync-engine,closeio/nylas,nylas/sync-engine,nylas/sync-engine,wakermahmud/sync-engine,wakermahmud/sync-engine,jobscore/sync-engine,Eagles2F/sync-engine,jobscore/sync-engine,closeio/nylas,gale320/sync-engine,gale320/sync-engine,nylas/sync-engine