fix search converters

pull/869/head
Thibault Duplessis 2015-08-30 18:49:31 +02:00
parent 0146290c1a
commit e40646922b
5 changed files with 8 additions and 10 deletions

View File

@ -25,9 +25,9 @@ private[analyse] final class PaginatorBuilder(
def slice(offset: Int, length: Int): Fu[Seq[Game]] = for {
ids $primitive[Analysis, String](
selector,
"_id",
_ sort sorting skip offset,
selector,
"_id",
_ sort sorting skip offset,
length.some)(_.asOpt[String])
games $find.byOrderedIds[Game](ids)
} yield games

View File

@ -40,7 +40,7 @@ final class Env(
private lazy val paginatorBuilder = new lila.search.PaginatorBuilder(
indexer = indexer,
maxPerPage = PaginatorMaxPerPage,
converter = res => postApi viewsFromIds (res.getHits.hits.toList map (_.id))
converter = res => postApi viewsFromIds res.hitIds
)
}

View File

@ -25,7 +25,7 @@ final class Env(
lazy val paginator = new lila.search.PaginatorBuilder(
indexer = indexer,
maxPerPage = PaginatorMaxPerPage,
converter = res => $find.byOrderedIds[lila.game.Game](res.getHits.hits.toList map (_.id)))
converter = res => $find.byOrderedIds[lila.game.Game](res.hitIds))
lazy val forms = new DataForm

View File

@ -3,8 +3,6 @@ package lila.search
import akka.actor.ActorRef
import akka.pattern.ask
import com.sksamuel.elastic4s.ElasticDsl._
import org.elasticsearch.action.count.CountResponse
import org.elasticsearch.action.search.SearchResponse
import lila.common.paginator._
import makeTimeout.large
@ -21,13 +19,13 @@ final class PaginatorBuilder[A](
def ids(query: Query, max: Int): Fu[List[String]] =
indexer ? actorApi.Search(query.searchDef(0, max)) map {
case res: SearchResponse => res.getHits.hits.toList map (_.id)
case res: SearchResponse => res.hitIds
}
private final class ESAdapter(query: Query) extends AdapterLike[A] {
def nbResults = indexer ? actorApi.Count(query.countDef) map {
case res: CountResponse => res.getCount.toInt
case res: CountResponse => res.count
}
def slice(offset: Int, length: Int) =

View File

@ -39,7 +39,7 @@ final class Env(
private lazy val paginatorBuilder = new lila.search.PaginatorBuilder(
indexer = indexer,
maxPerPage = PaginatorMaxPerPage,
converter = res => $find.byOrderedIds[lila.team.Team](res.getHits.hits.toList map (_.id))
converter = res => $find.byOrderedIds[lila.team.Team](res.hitIds)
)
}