This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.json4s._ | |
| import org.json4s.JsonDSL._ | |
| import spray.client.pipelining._ | |
| import spray.http._ | |
| import spray.httpx._ | |
| import spray.httpx.encoding._ | |
| import scala.concurrent._ | |
| import scala.concurrent.duration._ | |
| import akka.actor._ | |
| import scala.collection.mutable.ListBuffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val esReindexActor = system.actorOf(Props(new ElasticsearchReIndexerActor( | |
| "localhost:9200", | |
| "localhost:9200", | |
| "inputIndex", | |
| "outputIndex", | |
| "someType", | |
| doNothing)), name = "esReIndexer") | |
| esReindexActor ! "init" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import spray.client.pipelining._ | |
| import akka.actor.{ ActorRefFactory } | |
| import spray.http._ | |
| import spray.httpx._ | |
| import scala.concurrent.Future | |
| import scala.xml._ | |
| class KeywordService(keywordServiceURL: String, implicit val actorRefFactory: ActorRefFactory) { | |
| import actorRefFactory.dispatcher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class Terms( | |
| termIds: List[Int], | |
| status: Int = 0) | |
| case class DesiredTermDetails( | |
| ancestors: Boolean = false, | |
| category: Boolean = false, | |
| children: Boolean = false, | |
| translations: Boolean = true, | |
| mappingSynonyms: Boolean = false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scala.util.parsing.combinator._ | |
| import scala.util.parsing.combinator.syntactical._ | |
| case class Select(val fields: String*) | |
| case class From(val table: String) | |
| def selectAll: Parser[Select] = "select" ~ "*" ^^^ (Select("*")) //output: Select("*") | |
| def from: Parser[From] = "from" ~> ident ^^ (From(_)) //output: From("users") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def select: Parser[Select] = "select" ~ repsep(ident, ",") ^^ { | |
| case "select" ~ f => Select(f: _*) | |
| } | |
| //output: Select(List[String]("name", "age")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| case class Count(val field: String) | |
| def count: Parser[Count] = "select" ~ "count" ~> "(" ~> ident <~ ")" ^^ { | |
| case exp => Count(exp) | |
| } | |
| //output: Count("name") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Direction | |
| case class Asc(field: String*) extends Direction | |
| case class Desc(field: String*) extends Direction | |
| def order: Parser[Direction] = { | |
| "order" ~> "by" ~> ident ~ ("asc" | "desc") ^^ { | |
| case f ~ "asc" => Asc(f) | |
| case f ~ "desc" => Desc(f) | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class Direction | |
| case class Asc(field: String*) extends Direction | |
| case class Desc(field: String*) extends Direction | |
| def order: Parser[Direction] = { | |
| ("order" ~> "by" ~> ident ~ ("asc" | "desc") ^^ { | |
| case f ~ "asc" => Asc(f) | |
| case f ~ "desc" => Desc(f) | |
| }) | ("order" ~> "by" ~> repsep(ident, ",") ~ ("asc" | "desc") ^^ { | |
| case f ~ "asc" => Asc(f: _*) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def where: Parser[Where] = "where" ~> rep(predicate) ^^ (Where(_: _*)) | |
| def predicate = ( | |
| ident ~ "=" ~ wholeNumber ^^ { case f ~ "=" ~ i => NumberEquals(f, i.toInt) } | |
| | ident ~ "<" ~ wholeNumber ^^ { case f ~ "<" ~ i => LessThan(f, i.toInt) } | |
| | ident ~ ">" ~ wholeNumber ^^ { case f ~ ">" ~ i => GreaterThan(f, i.toInt) }) | |
| //output: GreaterThan("age", 30) |