Extracted createFieldsForAccountTransaction()

This commit is contained in:
dankito 2020-04-28 17:01:39 +02:00
parent 3829abe120
commit fb456c451a
1 changed files with 20 additions and 13 deletions

View File

@ -19,6 +19,7 @@ import net.dankito.utils.lucene.index.DocumentsWriter
import net.dankito.utils.lucene.index.FieldBuilder
import net.dankito.utils.serialization.ISerializer
import net.dankito.utils.serialization.JacksonJsonSerializer
import org.apache.lucene.index.IndexableField
import java.io.File
@ -36,6 +37,16 @@ open class LuceneBankingPersistence(
DocumentsWriter(LuceneConfig.getAccountTransactionsIndexFolder(indexFolder)).use { writer ->
transactions.forEach { transaction ->
writer.updateDocumentForNonNullFields(IdFieldName, transaction.id,
*createFieldsForAccountTransaction(bankAccount, transaction).toTypedArray()
)
}
writer.flushChangesToDisk()
}
}
protected open fun createFieldsForAccountTransaction(bankAccount: BankAccount, transaction: AccountTransaction): List<IndexableField?> {
return listOf(
fields.keywordField(BankAccountIdFieldName, bankAccount.id),
fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true),
fields.fullTextSearchField(UsageFieldName, transaction.usage, true),
@ -52,8 +63,4 @@ open class LuceneBankingPersistence(
)
}
writer.flushChangesToDisk()
}
}
}