refresh elasticsearch index after initial import

pull/2336/head
Thibault Duplessis 2016-10-23 15:28:23 +02:00
parent 21938169b7
commit b9ca802059
4 changed files with 9 additions and 3 deletions

View File

@ -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
}

View File

@ -125,5 +125,5 @@ final class GameSearchApi(client: ESClient) extends SearchReadApi[Game, Query] {
nowMillis
}
} void
}
} >> client.refresh
}

View File

@ -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
}

View File

@ -84,7 +84,7 @@ final class StudySearchApi(
Iteratee.foldM[Study, Unit](()) {
case (_, study) => doStore(study)
}
}
} >> client.refresh
case _ => funit
}
}