@@ -26,7 +26,7 @@ import kotlin.coroutines.cancellation.CancellationException
2626import kotlin.io.path.*
2727import kotlin.math.ceil
2828
29- typealias QueryKey = Triple < Int , String , QueryOrder ?>
29+ private data class QueryKey ( val pageCount : Int , val query : String , val order : QueryOrder ? , val similarity : Float )
3030
3131typealias PageResult = Pair <List <Map <String , String >>, Map <String , List <Map <String , String >>>>
3232
@@ -537,13 +537,18 @@ object DataServiceImpl : IDataService {
537537 return result
538538 }
539539
540- override fun getPage (query : String , isSemantic : Boolean , order : QueryOrder ? , pageCount : Int ): PageResult {
540+ override suspend fun getPage (
541+ query : String ,
542+ similarityScore : Float ,
543+ order : QueryOrder ? ,
544+ pageCount : Int ,
545+ ): PageResult {
541546
542547 if (this .currentPool == null || this .currentField == null ) return Pair (emptyList(), emptyMap())
543548
544- logger.info(" Query (${order ? : " None" } | Semantic : $isSemantic ): $query " )
549+ logger.info(" Query (${order ? : " None" } | Similarity : $similarityScore ): $query " )
545550
546- val key = Triple (pageCount, query, order)
551+ val key = QueryKey (pageCount, query, order, similarityScore )
547552
548553 pageCache.getIfPresent(key)?.let { return it }
549554
@@ -553,7 +558,8 @@ object DataServiceImpl : IDataService {
553558
554559 val (filterQuery, filter) = this .getPreFilter(query)
555560
556- val indexResult = dataPool.search(this .handleReplacements(dataPool.metadata, filterQuery), isSemantic)
561+ val indexResult =
562+ dataPool.search(this .handleReplacements(dataPool.metadata, filterQuery), similarityScore)
557563
558564 if (filter.isEmpty() && indexResult.isEmpty()) return Pair (emptyList(), emptyMap())
559565
@@ -589,7 +595,7 @@ object DataServiceImpl : IDataService {
589595 return result
590596 }
591597
592- override fun getPageCount (query : String , isSemantic : Boolean ): Triple <Long , Long , Set <String >> {
598+ override suspend fun getPageCount (query : String , similarityScore : Float ): Triple <Long , Long , Set <String >> {
593599 if (this .currentPool == null || this .currentField == null ) return Triple (- 1 , - 1 , emptySet())
594600
595601 val dataPool = this .dataPools[this .currentPool] ? : return Triple (- 1 , - 1 , emptySet())
@@ -598,7 +604,8 @@ object DataServiceImpl : IDataService {
598604
599605 val (filterQuery, filter) = this .getPreFilter(query)
600606
601- val indexResult = dataPool.search(handleReplacements(dataPool.metadata, filterQuery), isSemantic)
607+ val indexResult =
608+ dataPool.search(handleReplacements(dataPool.metadata, filterQuery), similarityScore)
602609
603610 if (filter.isEmpty() && indexResult.isEmpty()) return Triple (0 , 0 , emptySet())
604611
@@ -717,5 +724,4 @@ object DataServiceImpl : IDataService {
717724 ) null
718725 else token.trim()
719726 }
720- }
721-
727+ }
0 commit comments