From 596f85ca6d648b1e5fed89c2f61b175df041d9a0 Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 17 Sep 2020 01:51:12 +0200 Subject: [PATCH] Implemented matching only the start of a city name (with contains() there have been too many unwanted search results) --- .../kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt | 2 +- .../kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt index 04c47057..43701381 100644 --- a/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt +++ b/tools/BankFinder/src/commonMain/kotlin/net/dankito/banking/bankfinder/InMemoryBankFinder.kt @@ -39,7 +39,7 @@ open class InMemoryBankFinder() : BankFinderBase(), IBankFinder { protected open fun checkIfQueryMatchesBankNameOrCity(bankInfo: BankInfo, queryLowerCase: String): Boolean { return bankInfo.name.toLowerCase().contains(queryLowerCase) - || bankInfo.city.toLowerCase().contains(queryLowerCase) + || bankInfo.city.toLowerCase().startsWith(queryLowerCase) } diff --git a/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt b/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt index 2737ac73..8f86b03e 100644 --- a/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt +++ b/tools/LuceneBankFinder/src/main/kotlin/net/dankito/banking/bankfinder/LuceneBankFinder.kt @@ -93,7 +93,7 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder { val luceneQuery = queries.createQueriesForSingleTerms(query.toLowerCase()) { singleTerm -> listOf( queries.fulltextQuery(BankInfoNameFieldName, singleTerm), - queries.contains(BankInfoCityIndexedFieldName, singleTerm) + queries.startsWith(BankInfoCityIndexedFieldName, singleTerm) ) }