Skip to content

Commit

Permalink
Merge pull request #100 from barbulescu/convert-refresh-interval-to-d…
Browse files Browse the repository at this point in the history
…uration

change refreshInterval to Duration type
  • Loading branch information
jillesvangurp authored Jan 9, 2024
2 parents 8d163a2 + 7412eb3 commit 7717cb3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ client.createIndex(indexName) {
settings {
replicas = 0
shards = 3
refreshInterval = "10s"
refreshInterval = 10.seconds
}
mappings(dynamicEnabled = false) {
text(TestDocument::name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import documentation.manual.ManualPages
import documentation.mdLink
import documentation.sourceGitRepository
import kotlinx.coroutines.runBlocking
import kotlin.time.Duration.Companion.seconds

val indexManagementMd = sourceGitRepository.md {
val client = SearchClient(KtorRestClient(Node("localhost", 9999)))
Expand Down Expand Up @@ -54,7 +55,7 @@ val indexManagementMd = sourceGitRepository.md {
settings {
replicas = 1
shards = 3
refreshInterval = "10s"
refreshInterval = 10.seconds

analysis {
filter("2_5_edgengrams") {
Expand Down
5 changes: 2 additions & 3 deletions docs/src/test/kotlin/documentation/projectreadme/readme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package documentation.projectreadme

import com.jillesvangurp.kotlin4example.ExampleOutput
import com.jillesvangurp.kotlin4example.Kotlin4Example
import com.jillesvangurp.ktsearch.*
import com.jillesvangurp.searchdsls.querydsl.*
import documentation.githubLink
Expand All @@ -13,6 +11,7 @@ import documentation.printStdOut
import documentation.sourceGitRepository
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.Serializable
import kotlin.time.Duration.Companion.seconds

val projectReadme = sourceGitRepository.md {
+"""
Expand Down Expand Up @@ -103,7 +102,7 @@ val projectReadme = sourceGitRepository.md {
settings {
replicas = 0
shards = 3
refreshInterval = "10s"
refreshInterval = 10.seconds
}
mappings(dynamicEnabled = false) {
text(TestDocument::name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ suspend fun SearchClient.reindex(
return restClient.post {
path("_reindex")
parameter("refresh", refresh)
parameter("timeout", timeout.toElasticsearchTimeUnit())
parameter("timeout", timeout)
parameter("wait_for_active_shards", waitForActiveShards)
parameter("wait_for_completion", waitForCompletion)
parameter("requests_per_second", requestsPerSecond)
parameter("require_alias", requireAlias)
parameter("scroll", scroll.toElasticsearchTimeUnit())
parameter("scroll", scroll)
parameter("slices", slices)
parameter("max_docs", maxDocs)
body = reindexDSL.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ data class SearchAPIRequest(
}

fun parameter(key: String, value: Duration?) {
value?.let {
parameters[key] = "${value.inWholeSeconds}s"
value.toElasticsearchTimeUnit()?.let {
parameters[key] = it
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.kotest.matchers.shouldBe
import kotlinx.coroutines.test.runTest
import kotlinx.serialization.json.*
import kotlin.test.Test
import kotlin.time.Duration.Companion.seconds

class IndexCreateTest: SearchTestBase() {
@Test
Expand Down Expand Up @@ -33,7 +34,7 @@ class IndexCreateTest: SearchTestBase() {
settings {
replicas = 0
shards = 5
refreshInterval = "31s"
refreshInterval = 31.seconds
}
}
response.acknowledged shouldBe true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package com.jillesvangurp.searchdsls.mappingdsl

import com.jillesvangurp.jsondsl.*
import kotlin.reflect.KProperty
import kotlin.time.Duration

@Suppress("LeakingThis")
class Analysis : JsonDsl() {
Expand Down Expand Up @@ -67,7 +68,7 @@ class Analysis : JsonDsl() {
class IndexSettings : JsonDsl() {
var replicas: Int by property("index.number_of_replicas")
var shards: Int by property("index.number_of_shards")
var refreshInterval: String by property("index.refresh_interval")
var refreshInterval: Duration by property("index.refresh_interval")
var indexLifeCycleName: String by property("index.lifecycle.name")

fun analysis(block: Analysis.() -> Unit) {
Expand Down

0 comments on commit 7717cb3

Please sign in to comment.