From fe0e4f87d948df5c8b470b11be38526749b51438 Mon Sep 17 00:00:00 2001 From: username1103 Date: Wed, 29 Oct 2025 16:15:32 +0900 Subject: [PATCH] feat: add string value of equals operator --- .../search/EqualsSearchOperatorDsl.kt | 9 ++++++++ .../search/EqualsSearchOperatorDslTest.kt | 21 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDsl.kt b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDsl.kt index 10969c2e..cca0b79e 100644 --- a/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDsl.kt +++ b/core/src/main/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDsl.kt @@ -72,6 +72,15 @@ class EqualsSearchOperatorDsl { document["value"] = value } + /** + * Value to query for string, indexed as MongoDB Search token type. + * + * @param value Value must be a string. + */ + fun value(value: String) { + document["value"] = value + } + /** * The score assigned to matching search term results. Use one of the following options to modify the score: * diff --git a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDslTest.kt b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDslTest.kt index c7bef3d9..6f66f9bb 100644 --- a/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDslTest.kt +++ b/core/src/test/kotlin/com/github/inflab/spring/data/mongodb/core/aggregation/search/EqualsSearchOperatorDslTest.kt @@ -168,6 +168,27 @@ internal class EqualsSearchOperatorDslTest : FreeSpec({ """.trimIndent(), ) } + + "should build a value by String" { + // given + val operator = equal { + value("stringValue") + } + + // when + val result = operator.build() + + // then + result.shouldBeJson( + """ + { + "equals": { + "value": "stringValue" + } + } + """.trimIndent(), + ) + } } "score" - {