diff --git a/docker-compose-es-7.yml b/docker-compose-es-7.yml index 45bd0f36..be3a9586 100644 --- a/docker-compose-es-7.yml +++ b/docker-compose-es-7.yml @@ -1,12 +1,11 @@ -version: '2.2' services: es7: - image: docker.elastic.co/elasticsearch/elasticsearch:7.17.9 + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.22 environment: - cluster.name=docker-test-cluster - bootstrap.memory_lock=true - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" - cluster.routing.allocation.disk.threshold_enabled=true # make sure it works on nearly full disk - cluster.routing.allocation.disk.watermark.low=3gb diff --git a/docker-compose-es-8.yml b/docker-compose-es-8.yml index 8a0d5830..5607369d 100644 --- a/docker-compose-es-8.yml +++ b/docker-compose-es-8.yml @@ -1,12 +1,11 @@ -version: '2.2' services: es8: - image: docker.elastic.co/elasticsearch/elasticsearch:8.9.0 + image: docker.elastic.co/elasticsearch/elasticsearch:8.14.0 environment: - cluster.name=docker-test-cluster - bootstrap.memory_lock=true - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m" - cluster.routing.allocation.disk.threshold_enabled=true # make sure it works on nearly full disk - cluster.routing.allocation.disk.watermark.low=3gb diff --git a/docker-compose-os-1.yml b/docker-compose-os-1.yml index a07eb117..a4695310 100644 --- a/docker-compose-os-1.yml +++ b/docker-compose-os-1.yml @@ -1,4 +1,3 @@ -version: '2.2' services: os1: image: opensearchproject/opensearch:1 @@ -6,7 +5,7 @@ services: - cluster.name=docker-test-cluster - bootstrap.memory_lock=true - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" - cluster.routing.allocation.disk.threshold_enabled=true # make sure it works on nearly full disk - cluster.routing.allocation.disk.watermark.low=3gb diff --git a/docker-compose-os-2.yml b/docker-compose-os-2.yml index f7fd9384..88595163 100644 --- a/docker-compose-os-2.yml +++ b/docker-compose-os-2.yml @@ -1,19 +1,18 @@ -version: '2.2' services: os2: - image: opensearchproject/opensearch:2.8.0 + image: opensearchproject/opensearch:2.15.0 environment: - cluster.name=docker-test-cluster - bootstrap.memory_lock=true - discovery.type=single-node - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" - cluster.routing.allocation.disk.threshold_enabled=true # make sure it works on nearly full disk - cluster.routing.allocation.disk.watermark.low=3gb - cluster.routing.allocation.disk.watermark.high=2gb - cluster.routing.allocation.disk.watermark.flood_stage=1gb - cluster.routing.allocation.disk.threshold_enabled=false - - plugins.security.disabled=true + - DISABLE_SECURITY_PLUGIN=true ulimits: memlock: soft: -1 diff --git a/es_kibana/docker-compose.yml b/es_kibana/docker-compose.yml index c32eddc4..7d043181 100644 --- a/es_kibana/docker-compose.yml +++ b/es_kibana/docker-compose.yml @@ -2,7 +2,7 @@ version: "2.3" # simple docker compose to play with Elasticsearch & Kibana locally services: es: - image: docker.elastic.co/elasticsearch/elasticsearch:8.12.0 + image: docker.elastic.co/elasticsearch/elasticsearch:8.14.0 environment: discovery.type: "single-node" cluster.name: "docker-cluster" @@ -32,7 +32,7 @@ services: volumes: - data:/usr/share/elasticsearch/data kibana: - image: docker.elastic.co/kibana/kibana:8.12.0 + image: docker.elastic.co/kibana/kibana:8.14.0 environment: SERVER_NAME: localhost ELASTICSEARCH_URL: http://es:9200 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/search-client/src/commonMain/kotlin/com/jillesvangurp/ktsearch/search-api.kt b/search-client/src/commonMain/kotlin/com/jillesvangurp/ktsearch/search-api.kt index 787d3548..1e42371e 100644 --- a/search-client/src/commonMain/kotlin/com/jillesvangurp/ktsearch/search-api.kt +++ b/search-client/src/commonMain/kotlin/com/jillesvangurp/ktsearch/search-api.kt @@ -823,3 +823,21 @@ suspend fun SearchClient.msearch( @Serializable data class MultiSearchResponse(val took: Long, val responses: List) + +fun MultiSearchResponse.rrf(k: Int = 60): List> { + val aggregatedScores = mutableMapOf() + + // Score all the hits based on their aggregate ranking across the results + this.responses.forEach { searchResponse -> + // Process each SearchHit in the SearchResponse + searchResponse.hits?.hits.orEmpty().forEachIndexed { rank, searchHit -> + // Calculate the RRF score and add it to the aggregated score + val score = 1.0 / (k + rank) + + aggregatedScores[searchHit.id] = (aggregatedScores[searchHit.id]?:0.0) + score + } + } + + // Convert the aggregated scores to a sorted list + return aggregatedScores.toList().sortedByDescending { it.second } +} diff --git a/versions.properties b/versions.properties index a2edd72a..85daccbc 100644 --- a/versions.properties +++ b/versions.properties @@ -7,7 +7,7 @@ #### suppress inspection "SpellCheckingInspection" for whole file #### suppress inspection "UnusedProperty" for whole file -plugin.com.avast.gradle.docker-compose=0.17.6 +plugin.com.avast.gradle.docker-compose=0.17.7 plugin.org.jetbrains.dokka=1.9.20 @@ -29,19 +29,19 @@ version.junit.jupiter=5.10.2 ## # available=5.11.0-M1 ## # available=5.11.0-M2 -version.kotest=5.9.0 +version.kotest=5.9.1 version.kotlin=2.0.0 +## # available=2.0.20-Beta1 version.kotlinx.coroutines=1.8.1 ## # available=1.9.0-RC version.kotlinx.datetime=0.6.0 -version.kotlinx.serialization=1.6.3 -## # available=1.7.0-RC +version.kotlinx.serialization=1.7.1 - version.ktor=2.3.11 + version.ktor=2.3.12 ### available=3.0.0-beta-1 version.org.apache.logging.log4j..log4j-to-slf4j=2.23.1