Extracted createFieldsForAccountTransaction()
This commit is contained in:
parent
3829abe120
commit
fb456c451a
|
@ -19,6 +19,7 @@ import net.dankito.utils.lucene.index.DocumentsWriter
|
||||||
import net.dankito.utils.lucene.index.FieldBuilder
|
import net.dankito.utils.lucene.index.FieldBuilder
|
||||||
import net.dankito.utils.serialization.ISerializer
|
import net.dankito.utils.serialization.ISerializer
|
||||||
import net.dankito.utils.serialization.JacksonJsonSerializer
|
import net.dankito.utils.serialization.JacksonJsonSerializer
|
||||||
|
import org.apache.lucene.index.IndexableField
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +37,16 @@ open class LuceneBankingPersistence(
|
||||||
DocumentsWriter(LuceneConfig.getAccountTransactionsIndexFolder(indexFolder)).use { writer ->
|
DocumentsWriter(LuceneConfig.getAccountTransactionsIndexFolder(indexFolder)).use { writer ->
|
||||||
transactions.forEach { transaction ->
|
transactions.forEach { transaction ->
|
||||||
writer.updateDocumentForNonNullFields(IdFieldName, transaction.id,
|
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.keywordField(BankAccountIdFieldName, bankAccount.id),
|
||||||
fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true),
|
fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true),
|
||||||
fields.fullTextSearchField(UsageFieldName, transaction.usage, true),
|
fields.fullTextSearchField(UsageFieldName, transaction.usage, true),
|
||||||
|
@ -52,8 +63,4 @@ open class LuceneBankingPersistence(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.flushChangesToDisk()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue