mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Refactor solr language fields
This commit is contained in:
parent
26dff18ae0
commit
94bb18c152
@ -21,28 +21,18 @@ object Field {
|
|||||||
val discriminator = Field("discriminator")
|
val discriminator = Field("discriminator")
|
||||||
val attachmentName = Field("attachmentName")
|
val attachmentName = Field("attachmentName")
|
||||||
val content = Field("content")
|
val content = Field("content")
|
||||||
val content_de = Field("content_de")
|
val content_de = contentField(Language.German)
|
||||||
val content_en = Field("content_en")
|
val content_en = contentField(Language.English)
|
||||||
val content_fr = Field("content_fr")
|
val content_fr = contentField(Language.French)
|
||||||
val content_it = Field("content_it")
|
|
||||||
val content_es = Field("content_es")
|
|
||||||
val itemName = Field("itemName")
|
val itemName = Field("itemName")
|
||||||
val itemNotes = Field("itemNotes")
|
val itemNotes = Field("itemNotes")
|
||||||
val folderId = Field("folder")
|
val folderId = Field("folder")
|
||||||
|
|
||||||
|
val contentLangFields = Language.all
|
||||||
|
.map(contentField)
|
||||||
|
|
||||||
def contentField(lang: Language): Field =
|
def contentField(lang: Language): Field =
|
||||||
lang match {
|
Field(s"content_${lang.iso2}")
|
||||||
case Language.German =>
|
|
||||||
Field.content_de
|
|
||||||
case Language.English =>
|
|
||||||
Field.content_en
|
|
||||||
case Language.French =>
|
|
||||||
Field.content_fr
|
|
||||||
case Language.Italian =>
|
|
||||||
Field.content_it
|
|
||||||
case Language.Spanish =>
|
|
||||||
Field.content_es
|
|
||||||
}
|
|
||||||
|
|
||||||
implicit val jsonEncoder: Encoder[Field] =
|
implicit val jsonEncoder: Encoder[Field] =
|
||||||
Encoder.encodeString.contramap(_.name)
|
Encoder.encodeString.contramap(_.name)
|
||||||
|
@ -37,15 +37,10 @@ object SolrQuery {
|
|||||||
cfg,
|
cfg,
|
||||||
List(
|
List(
|
||||||
Field.content,
|
Field.content,
|
||||||
Field.content_de,
|
|
||||||
Field.content_en,
|
|
||||||
Field.content_fr,
|
|
||||||
Field.content_it,
|
|
||||||
Field.content_es,
|
|
||||||
Field.itemName,
|
Field.itemName,
|
||||||
Field.itemNotes,
|
Field.itemNotes,
|
||||||
Field.attachmentName
|
Field.attachmentName
|
||||||
),
|
) ++ Field.contentLangFields,
|
||||||
List(
|
List(
|
||||||
Field.id,
|
Field.id,
|
||||||
Field.itemId,
|
Field.itemId,
|
||||||
|
@ -56,7 +56,7 @@ object SolrSetup {
|
|||||||
5,
|
5,
|
||||||
solrEngine,
|
solrEngine,
|
||||||
"Add content_fr field",
|
"Add content_fr field",
|
||||||
addContentFrField.map(_ => FtsMigration.Result.workDone)
|
addContentField(Language.French).map(_ => FtsMigration.Result.workDone)
|
||||||
),
|
),
|
||||||
FtsMigration[F](
|
FtsMigration[F](
|
||||||
6,
|
6,
|
||||||
@ -68,27 +68,19 @@ object SolrSetup {
|
|||||||
7,
|
7,
|
||||||
solrEngine,
|
solrEngine,
|
||||||
"Add content_it field",
|
"Add content_it field",
|
||||||
addContentItField.map(_ => FtsMigration.Result.reIndexAll)
|
addContentField(Language.Italian).map(_ => FtsMigration.Result.reIndexAll)
|
||||||
),
|
),
|
||||||
FtsMigration[F](
|
FtsMigration[F](
|
||||||
8,
|
8,
|
||||||
solrEngine,
|
solrEngine,
|
||||||
"Add content_es field",
|
"Add content_es field",
|
||||||
addTextField(Some(Language.Spanish))(Field.content_es).map(_ =>
|
addContentField(Language.Spanish).map(_ => FtsMigration.Result.reIndexAll)
|
||||||
FtsMigration.Result.reIndexAll
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def addFolderField: F[Unit] =
|
def addFolderField: F[Unit] =
|
||||||
addStringField(Field.folderId)
|
addStringField(Field.folderId)
|
||||||
|
|
||||||
def addContentFrField: F[Unit] =
|
|
||||||
addTextField(Some(Language.French))(Field.content_fr)
|
|
||||||
|
|
||||||
def addContentItField: F[Unit] =
|
|
||||||
addTextField(Some(Language.Italian))(Field.content_it)
|
|
||||||
|
|
||||||
def setupCoreSchema: F[Unit] = {
|
def setupCoreSchema: F[Unit] = {
|
||||||
val cmds0 =
|
val cmds0 =
|
||||||
List(
|
List(
|
||||||
@ -130,6 +122,9 @@ object SolrSetup {
|
|||||||
run(DeleteField.command(DeleteField(field))).attempt *>
|
run(DeleteField.command(DeleteField(field))).attempt *>
|
||||||
run(AddField.command(AddField.string(field)))
|
run(AddField.command(AddField.string(field)))
|
||||||
|
|
||||||
|
private def addContentField(lang: Language): F[Unit] =
|
||||||
|
addTextField(Some(lang))(Field.contentField(lang))
|
||||||
|
|
||||||
private def addTextField(lang: Option[Language])(field: Field): F[Unit] =
|
private def addTextField(lang: Option[Language])(field: Field): F[Unit] =
|
||||||
lang match {
|
lang match {
|
||||||
case None =>
|
case None =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user