diff --git a/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt b/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt index 8475aa32..5596a417 100644 --- a/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt +++ b/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt @@ -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,19 +37,7 @@ open class LuceneBankingPersistence( DocumentsWriter(LuceneConfig.getAccountTransactionsIndexFolder(indexFolder)).use { writer -> transactions.forEach { transaction -> writer.updateDocumentForNonNullFields(IdFieldName, transaction.id, - fields.keywordField(BankAccountIdFieldName, bankAccount.id), - fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true), - fields.fullTextSearchField(UsageFieldName, transaction.usage, true), - fields.nullableFullTextSearchField(BookingTextFieldName, transaction.bookingText, true), - - fields.nullableStoredField(OtherPartyBankCodeFieldName, transaction.otherPartyBankCode), - fields.nullableStoredField(OtherPartyAccountIdFieldName, transaction.otherPartyAccountId), - fields.storedField(BookingDateFieldName, transaction.bookingDate), - fields.storedField(AmountFieldName, transaction.amount), - fields.storedField(CurrencyFieldName, transaction.currency), - fields.nullableStoredField(BalanceFieldName, transaction.balance), - - fields.sortField(BookingDateSortFieldName, transaction.bookingDate) + *createFieldsForAccountTransaction(bankAccount, transaction).toTypedArray() ) } @@ -56,4 +45,22 @@ open class LuceneBankingPersistence( } } + protected open fun createFieldsForAccountTransaction(bankAccount: BankAccount, transaction: AccountTransaction): List { + return listOf( + fields.keywordField(BankAccountIdFieldName, bankAccount.id), + fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true), + fields.fullTextSearchField(UsageFieldName, transaction.usage, true), + fields.nullableFullTextSearchField(BookingTextFieldName, transaction.bookingText, true), + + fields.nullableStoredField(OtherPartyBankCodeFieldName, transaction.otherPartyBankCode), + fields.nullableStoredField(OtherPartyAccountIdFieldName, transaction.otherPartyAccountId), + fields.storedField(BookingDateFieldName, transaction.bookingDate), + fields.storedField(AmountFieldName, transaction.amount), + fields.storedField(CurrencyFieldName, transaction.currency), + fields.nullableStoredField(BalanceFieldName, transaction.balance), + + fields.sortField(BookingDateSortFieldName, transaction.bookingDate) + ) + } + } \ No newline at end of file