Skip to content

Commit c1f2415

Browse files
authored
PI-2526 Fix semantic sorting + switch to minScore instead of knn (#785)
1 parent 23385d1 commit c1f2415

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/kotlin/uk/gov/justice/hmpps/probationsearch/contactsearch/ContactSearchService.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class ContactSearchService(
100100
query.neural {
101101
it.field("textEmbedding.knn")
102102
.queryText(request.query)
103-
.k(10)
103+
.minScore(0.01F)
104104
}
105105
}
106106
}.toQuery()
@@ -255,7 +255,7 @@ private fun Sort.fieldSorts() = SortType.entries.flatMap { type ->
255255
SortBuilders.fieldSort(type.searchField).order(it.direction.toSortOrder())
256256
}
257257
}
258-
}
258+
}.ifEmpty { listOf(SortBuilders.fieldSort(SCORE.searchField).order(SortOrder.DESC)) }
259259

260260
private fun SearchRequest.Builder.sorted(sorts: List<FieldSortBuilder>): SearchRequest.Builder {
261261
sorted(sorts) { fieldSorts ->

0 commit comments

Comments
 (0)