Skip to content

Instantly share code, notes, and snippets.

@takezoe
Last active August 29, 2015 14:10
Show Gist options
  • Save takezoe/689fd8ec21d0de43f60d to your computer and use it in GitHub Desktop.
Save takezoe/689fd8ec21d0de43f60d to your computer and use it in GitHub Desktop.
Experimental implementation of Elasticsearch4s Async API
///////////////////////////////////////////////////////////////
// Elasticsearch4s is a Scala client for Elasticsearch
// https://github.com/bizreach/elasticsearch4s
///////////////////////////////////////////////////////////////
val config = ESConfig("my_index", "my_type")
// Use AsyncESClient instead of ESClient
AsyncESClient.using("http://localhost:9200"){ client =>
val future = client.searchAsync(config){ searcher =>
searcher.setQuery(QueryBuilders.matchPhraseQuery("subject", "Hello"))
}
future.foreach { map =>
println(map)
}
}
// Shutdown AsyncHttpClient
AsyncESClient.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment