Skip to content

Instantly share code, notes, and snippets.

@akirillov
Last active August 29, 2015 14:01
Show Gist options
  • Save akirillov/00c4d337dbc5c9ea4cbc to your computer and use it in GitHub Desktop.
Save akirillov/00c4d337dbc5c9ea4cbc to your computer and use it in GitHub Desktop.
trait ElasticSearchClient {
val indexName: String
val typeName: String
def executeWithESClient[T](f: TransportClient => T) = {
ElasticSearchTransport.transportClient.map(f)
}
def saveDocument(document: String, docId: String) = {
executeWithESClient { client =>
client.prepareIndex(indexName, typeName, docId)
.setSource(document)
.execute()
.actionGet
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment