1
1
package uk.gov.justice.hmpps.probationsearch.contactsearch
2
2
3
3
import com.fasterxml.jackson.databind.ObjectMapper
4
- import com.microsoft.applicationinsights.TelemetryClient
5
4
import io.opentelemetry.api.trace.Span
6
5
import io.opentelemetry.context.Context
7
6
import io.opentelemetry.extension.kotlin.asContextElement
@@ -39,7 +38,6 @@ import uk.gov.justice.hmpps.probationsearch.contactsearch.ContactSearchService.S
39
38
import uk.gov.justice.hmpps.probationsearch.services.DeliusService
40
39
import uk.gov.justice.hmpps.sqs.audit.HmppsAuditService
41
40
import java.time.Instant
42
- import java.time.temporal.ChronoUnit
43
41
import org.opensearch.client.opensearch._types.SortOrder as JavaClientSortOrder
44
42
import org.opensearch.client.opensearch._types.query_dsl.Operator as JavaClientOperator
45
43
@@ -50,7 +48,6 @@ class ContactSearchService(
50
48
private val objectMapper : ObjectMapper ,
51
49
private val deliusService : DeliusService ,
52
50
private val openSearchClient : OpenSearchClient ,
53
- private val telemetryClient : TelemetryClient
54
51
) {
55
52
56
53
private val scope = CoroutineScope (Context .current().asContextElement())
@@ -81,7 +78,6 @@ class ContactSearchService(
81
78
}
82
79
83
80
fun semanticSearch (request : ContactSearchRequest , pageable : Pageable ): ContactSearchResponse {
84
- val started = Instant .now()
85
81
audit(request, pageable)
86
82
87
83
val indexName = " contact-semantic-search-${request.crn.lowercase()} "
@@ -111,7 +107,6 @@ class ContactSearchService(
111
107
val searchRequest = SearchRequest .of { searchRequest ->
112
108
searchRequest
113
109
.index(indexName)
114
- .source { source -> source.filter { it.excludes(" textEmbedding" , " textChunks" ) } }
115
110
.query { query -> query.hybrid { hybrid -> hybrid.queries(keywordQuery, semanticQuery) } }
116
111
.trackTotalHits(TrackHits .of { it.count(5000 ) })
117
112
.size(pageable.pageSize)
@@ -143,19 +138,6 @@ class ContactSearchService(
143
138
}
144
139
val response = PageImpl (results, pageable, searchResponse.hits().total().value())
145
140
146
- telemetryClient.trackEvent(
147
- " SemanticSearchCompleted" ,
148
- mapOf (
149
- " crn" to request.crn,
150
- " query" to request.query.length.toString(),
151
- " jsonQuery" to searchRequest.toJsonString(),
152
- " resultCount" to response.totalElements.toString(),
153
- ),
154
- mapOf (
155
- " duration" to started.until(Instant .now(), ChronoUnit .MILLIS ).toDouble(),
156
- ),
157
- )
158
-
159
141
return ContactSearchResponse (
160
142
response.numberOfElements,
161
143
response.pageable.pageNumber,
0 commit comments