tweak search result ranking
This commit is contained in:
@@ -433,8 +433,8 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
b.score.score
|
||||
}
|
||||
|
||||
val aTotal = aScore * 0.7f + aWeight.toFloat() * 0.3f
|
||||
val bTotal = bScore * 0.7f + bWeight.toFloat() * 0.3f
|
||||
val aTotal = aScore * 0.6f + aWeight.toFloat() * 0.4f
|
||||
val bTotal = bScore * 0.6f + bWeight.toFloat() * 0.4f
|
||||
|
||||
bTotal.compareTo(aTotal)
|
||||
}
|
||||
|
||||
@@ -43,9 +43,10 @@ value class ResultScore private constructor(private val packed: Long) : Comparab
|
||||
|
||||
/**
|
||||
* A total score for the result, combining the similarity with additional factors.
|
||||
* The score is normalized to be between 0 and 1.
|
||||
*/
|
||||
val score: Float
|
||||
get() = (similarity + (if (isPrefix) 0.8f else 0f) + (if (isSubstring) 0.8f else 0f)) * (if (isPrimary) 1f else 0.8f)
|
||||
get() = (similarity + (if (isPrefix) 0.2f else 0f) + (if (isSubstring) 0.8f else 0f)).coerceIn(0f, 1f) * (if (isPrimary) 1f else 0.8f)
|
||||
|
||||
override fun compareTo(other: ResultScore): Int {
|
||||
return score.compareTo(other.score)
|
||||
|
||||
@@ -183,7 +183,7 @@ interface SearchableDao {
|
||||
@Query("UPDATE Searchable SET launchCount = launchCount + 1 WHERE `key` = :key")
|
||||
fun incrementLaunchCount(key: String)
|
||||
|
||||
@Query("UPDATE Searchable SET `weight` = `weight` * (1.0 - :alpha) WHERE `key` != :key")
|
||||
@Query("UPDATE Searchable SET `weight` = `weight` * (1.0 - :alpha) WHERE `key` != :key AND weight > 0.001")
|
||||
fun reduceWeightExcept(key: String, alpha: Double)
|
||||
|
||||
@Query("UPDATE Searchable SET `weight` = `weight` + :alpha * (1.0 - `weight`) WHERE `key` == :key")
|
||||
|
||||
Reference in New Issue
Block a user