A simple try to add fuzzy search in sqlite database.
Step 1. Add the JitPack repository to your build file
Add it in your root build.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.fcat97:fuzzyble-java:Tag'
}
There are four main components that are exposed to the users of this library.
- FuzzybleCursor: To manipulate the fuzzy utilities get an instance of
FuzzyCursor
. It can perform the following functions:- Create required data for fuzzy search.
- Get fuzzy suggestion for any text.
- Fuzzyble: To make a database fuzzy searchable, implement the
Fuzzyble
interface on it. Some databases are immutable. For example, android'sRoom
database. The schema need to be defined during compile time, so an auxiliary mutable database is needed.- Immutable Database: This database works as read-only source database. This contains actual text on which search will be performed.
- Mutable Database: This database is used to store required data for fuzzy search. If the source database itself
mutable
, there is no need to provide an addition database. Sincemutable
database can be used for both application i.e. source and sink data.
- Strategy: Defines how to generate and store required data for fuzzy matching.
- WordLen: Simpler approach to find similar words.
- Trigram: Trigram approach for finding suggestion.
- Implement
Strategy
class to provide better solution.
- Similarity: How to calculate if two words are similar? Currently, have:
- Levenshtein Distance