Skip to content

Instantly share code, notes, and snippets.

@jkyamog
Last active December 22, 2015 19:49
Show Gist options
  • Save jkyamog/6521880 to your computer and use it in GitHub Desktop.
Save jkyamog/6521880 to your computer and use it in GitHub Desktop.
consuming autosource findByStream and using for solr batch indexes.
def batchInsert(elems: Enumerator[Iterator[T]])(implicit ctx: ExecutionContext): Future[Unit] = {
val indexByChunks = Iteratee.foreach[Iterator[T]] { i =>
i.grouped(batchSize).foreach { chunk =>
val json = Json.toJson(chunk)(Writes.seq)
solr.index(json)
}
}
elems run indexByChunks
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment