refresh elasticsearch index after initial import
parent
21938169b7
commit
b9ca802059
|
@ -46,7 +46,7 @@ final class ForumSearchApi(
|
|||
_ <- c.storeBulk(views map (v => Id(v.post.id) -> toDoc(v)))
|
||||
} yield Cursor.Cont({})
|
||||
}
|
||||
}
|
||||
} >> client.refresh
|
||||
|
||||
case _ => funit
|
||||
}
|
||||
|
|
|
@ -125,5 +125,5 @@ final class GameSearchApi(client: ESClient) extends SearchReadApi[Game, Query] {
|
|||
nowMillis
|
||||
}
|
||||
} void
|
||||
}
|
||||
} >> client.refresh
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ sealed trait ESClient {
|
|||
def deleteById(id: Id): Funit
|
||||
|
||||
def deleteByIds(ids: List[Id]): Funit
|
||||
|
||||
def refresh: Funit
|
||||
}
|
||||
|
||||
final class ESClientHttp(
|
||||
|
@ -48,6 +50,9 @@ final class ESClientHttp(
|
|||
case (Id(id), doc) => id -> JsString(Json.stringify(doc))
|
||||
}))
|
||||
|
||||
def refresh =
|
||||
HTTP(s"refresh/${index.name}", Json.obj())
|
||||
|
||||
private[search] def HTTP[D: Writes, R](url: String, data: D, read: String => R): Fu[R] =
|
||||
WS.url(s"$endpoint/$url").post(Json toJson data) flatMap {
|
||||
case res if res.status == 200 => fuccess(read(res.body))
|
||||
|
@ -69,4 +74,5 @@ final class ESClientStub extends ESClient {
|
|||
def deleteById(id: Id) = funit
|
||||
def deleteByIds(ids: List[Id]) = funit
|
||||
def putMapping = funit
|
||||
def refresh = funit
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ final class StudySearchApi(
|
|||
Iteratee.foldM[Study, Unit](()) {
|
||||
case (_, study) => doStore(study)
|
||||
}
|
||||
}
|
||||
} >> client.refresh
|
||||
case _ => funit
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue