Skip to content

Commit

Permalink
upgrade elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 16, 2014
1 parent ab7bdb0 commit 0a6f1bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
8 changes: 5 additions & 3 deletions modules/forumSearch/src/main/Indexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import akka.actor._
import akka.pattern.pipe
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.mapping.FieldType._
import com.sksamuel.elastic4s.mappings.FieldType._

import lila.forum.actorApi._
import lila.forum.{ Post, PostLiteView, PostApi }
Expand Down Expand Up @@ -59,8 +59,10 @@ private[forumSearch] final class Indexer(
Await.result(
$enumerate.bulk[Option[Post]]($query[Post](Json.obj()), 200) { postOptions =>
(postApi liteViews postOptions.flatten) flatMap { views =>
client bulk {
(views map store): _*
client execute {
bulk {
(views map store): _*
}
} void
}
}, 20 minutes)
Expand Down
12 changes: 7 additions & 5 deletions modules/gameSearch/src/main/Indexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import akka.actor._
import akka.pattern.pipe
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.mapping.FieldType._
import com.sksamuel.elastic4s.mappings.FieldType._

import lila.game.GameRepo
import lila.game.actorApi.{ InsertGame, FinishGame }
import lila.game.GameRepo
import lila.search.actorApi._
import lila.search.ElasticSearch

Expand Down Expand Up @@ -59,7 +59,7 @@ private[gameSearch] final class Indexer(
import lila.db.api._
import lila.game.tube.gameTube
loginfo("[game search] counting games...")
val size = $count($select.all).await
val size = SprayPimpedFuture($count($select.all)).await
val batchSize = 1000
var nb = 0
var nbSkipped = 0
Expand All @@ -69,8 +69,10 @@ private[gameSearch] final class Indexer(
val games = gameOptions.flatten filter storable
val nbGames = games.size
(GameRepo filterAnalysed games.map(_.id).toSeq flatMap { analysedIds =>
client bulk {
games.map { g => store(g, analysedIds(g.id)) }: _*
client execute {
bulk {
games.map { g => store(g, analysedIds(g.id)) }: _*
}
}
}).void >>- {
nb = nb + nbGames
Expand Down
10 changes: 6 additions & 4 deletions modules/teamSearch/src/main/Indexer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import akka.actor._
import akka.pattern.pipe
import com.sksamuel.elastic4s.ElasticClient
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.mapping.FieldType._
import com.sksamuel.elastic4s.mappings.FieldType._

import lila.search.actorApi._
import lila.team.actorApi._
Expand All @@ -22,7 +22,7 @@ private[teamSearch] final class Indexer(
case Search(definition) => client execute definition pipeTo sender
case Count(definition) => client execute definition pipeTo sender

case InsertTeam(team) => client execute store(team)
case InsertTeam(team) => client execute store(team)

case RemoveTeam(id) => client execute {
delete id id from indexType
Expand All @@ -46,8 +46,10 @@ private[teamSearch] final class Indexer(
import lila.team.tube.teamTube
Await.result(
$enumerate.bulk[Option[Team]]($query[Team](Json.obj("enabled" -> true)), 100) { teamOptions =>
client bulk {
(teamOptions.flatten map store): _*
client execute {
bulk {
(teamOptions.flatten map store): _*
}
} void
}, 20 minutes)
sender ! (())
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object Dependencies {
val hasher = "com.roundeights" %% "hasher" % "1.0.0"
val jgit = "org.eclipse.jgit" % "org.eclipse.jgit" % "3.2.0.201312181205-r"
val jodaTime = "joda-time" % "joda-time" % "2.3"
val elastic4s = "com.sksamuel.elastic4s" %% "elastic4s" % "1.1.2.0"
val elastic4s = "com.sksamuel.elastic4s" %% "elastic4s" % "1.3.2"
val RM = "org.reactivemongo" %% "reactivemongo" % "0.11.0-SNAPSHOT"
val PRM = "org.reactivemongo" %% "play2-reactivemongo" % "0.11.0-SNAPSHOT"
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.2.2-THIB"
Expand Down

0 comments on commit 0a6f1bb

Please sign in to comment.