Wrote my own implementation for search:
private fun searchRequest(index: Index,
indexType: IndexType,
source: SearchSourceBuilder): SearchResponse {
val searchRequest = SearchRequest(index.index)
.types(indexType.type)
.source(source)
val request = Converter.createSearchRequest(searchRequest).entity.content
val writer = StringWriter()
IOUtils.copy(request, StringWriter(), StandardCharsets.UTF_8.name())
val httpEntity = HttpEntity(writer.toString(), getHeders())
val postForEntity = restTemplateElastic.postForEntity(getHost(), httpEntity, String::class.java)
val httpEntityResponse = BasicHttpEntity()
httpEntityResponse.content = IOUtils.toInputStream(postForEntity.body, StandardCharsets.UTF_8.name())
return Converter.createSearchResponse(httpEntityResponse, restHighLevelClient)
}
It's quicker than the standard implementation
My implementation:
Lifting the server siege...
Transactions: 25226 hits
Availability: 100.00 %
Elapsed time: 61.06 secs
Data transferred: 314.29 MB
Response time: 0.24 secs
Transaction rate: 413.13 trans/sec
Throughput: 5.15 MB/sec
Concurrency: 99.83
Successful transactions: 25226
Failed transactions: 0
Longest transaction: 8.00
Shortest transaction: 0.06
RestHighLevelClient.search
Lifting the server siege...
Transactions: 1886 hits
Availability: 100.00 %
Elapsed time: 60.78 secs
Data transferred: 23.49 MB
Response time: 3.15 secs
Transaction rate: 31.03 trans/sec
Throughput: 0.39 MB/sec
Concurrency: 97.60
Successful transactions: 1886
Failed transactions: 0
Longest transaction: 6.77
Shortest transaction: 0.80