-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15576 from lenguyenthanh/lila-search-team-ingestor
Lila search team ingestor
- Loading branch information
Showing
8 changed files
with
6 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,14 @@ | ||
package lila.teamSearch | ||
|
||
import akka.stream.scaladsl.* | ||
|
||
import lila.core.team.TeamData | ||
import lila.search.* | ||
import lila.search.client.SearchClient | ||
import lila.search.spec.{ Query, TeamSource } | ||
import lila.search.spec.Query | ||
|
||
final class TeamSearchApi( | ||
client: SearchClient, | ||
teamApi: lila.core.team.TeamApi | ||
)(using Executor, akka.stream.Materializer) | ||
extends SearchReadApi[TeamId, Query.Team]: | ||
final class TeamSearchApi(client: SearchClient)(using Executor) extends SearchReadApi[TeamId, Query.Team]: | ||
|
||
def search(query: Query.Team, from: From, size: Size) = | ||
client | ||
.search(query, from, size) | ||
.map: res => | ||
res.hitIds.map(TeamId.apply) | ||
.map(_.hitIds.map(TeamId.apply)) | ||
|
||
def count(query: Query.Team) = client.count(query).dmap(_.count) | ||
|
||
def store(team: TeamData) = client.storeTeam(team.id.value, toDoc(team)) | ||
|
||
private def toDoc(team: TeamData) = | ||
TeamSource( | ||
name = team.name, | ||
description = team.description.value.take(10000), | ||
nbMembers = team.nbMembers | ||
) | ||
|
||
def reset = | ||
client.mapping(index) >> { | ||
|
||
logger.info(s"Index to ${index}") | ||
|
||
teamApi.cursor | ||
.documentSource() | ||
.via(lila.common.LilaStream.logRate[TeamData]("team index")(logger)) | ||
.map(t => t.id.value -> toDoc(t)) | ||
.grouped(200) | ||
.mapAsync(1)(xs => client.storeBulkTeam(xs.toList)) | ||
.runWith(Sink.ignore) | ||
} >> client.refresh(index) |
This file contains 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