File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
src/main/scala/de/upb/cs/swt/delphi/webapi Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ package de .upb .cs .swt .delphi .webapi
2+
3+ import com .sksamuel .elastic4s .http .ElasticDsl ._
4+ import com .sksamuel .elastic4s .http .HttpClient
5+
6+ object ElasticClient {
7+
8+ val configuration = new Configuration ()
9+ val client = HttpClient (configuration.elasticsearchClientUri)
10+ val index = " delphi" / " project"
11+
12+ // Returns an entry with the given ID as an option
13+ def getSource (id : String ) =
14+ client.execute{
15+ get(id).from(index)
16+ }.await match {
17+ case Right (res) => res.body
18+ case Left (_) => Option .empty
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ object Server extends HttpApp with JsonSupport {
3434
3535 def retrieve (identifier : String ) = {
3636 get {
37- complete(identifier)
37+ complete(
38+ ElasticClient .getSource(identifier)
39+ )
3840 }
3941 }
4042
You can’t perform that action at this time.
0 commit comments