Skip to content

Commit 1aae089

Browse files
committed
Some fixes.
1 parent 61a4949 commit 1aae089

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

modules/integration/src/test/scala/zio/elasticsearch/HttpExecutorSpec.scala

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,15 +2800,20 @@ object HttpExecutorSpec extends IntegrationSpec {
28002800
val term = "apple"
28012801
val docWithTerm = doc.copy(stringField = s"$term banana orange")
28022802

2803-
val query = intervals(
2804-
"stringField",
2805-
intervalMatch(term)
2806-
)
2807-
28082803
for {
28092804
_ <- Executor.execute(ElasticRequest.upsert(firstSearchIndex, docId, docWithTerm))
28102805
_ <- Executor.execute(ElasticRequest.refresh(firstSearchIndex))
2811-
res <- Executor.execute(ElasticRequest.search(firstSearchIndex, query)).documentAs[TestDocument]
2806+
res <- Executor
2807+
.execute(
2808+
ElasticRequest.search(
2809+
firstSearchIndex,
2810+
intervals(
2811+
TestDocument.stringField,
2812+
intervalMatch(term)
2813+
)
2814+
)
2815+
)
2816+
.documentAs[TestDocument]
28122817
} yield assert(res)(Assertion.contains(docWithTerm))
28132818
}
28142819
} @@ around(
@@ -2817,15 +2822,20 @@ object HttpExecutorSpec extends IntegrationSpec {
28172822
),
28182823
test("intervalMatch query does not find document if term is absent") {
28192824
checkOnce(genDocumentId, genTestDocument) { (docId, doc) =>
2820-
val query = intervals(
2821-
"stringField",
2822-
intervalMatch("nonexistentterm")
2823-
)
2824-
28252825
for {
28262826
_ <- Executor.execute(ElasticRequest.upsert(firstSearchIndex, docId, doc))
28272827
_ <- Executor.execute(ElasticRequest.refresh(firstSearchIndex))
2828-
res <- Executor.execute(ElasticRequest.search(firstSearchIndex, query)).documentAs[TestDocument]
2828+
res <- Executor
2829+
.execute(
2830+
ElasticRequest.search(
2831+
firstSearchIndex,
2832+
intervals(
2833+
TestDocument.stringField,
2834+
intervalMatch("nonexistentterm")
2835+
)
2836+
)
2837+
)
2838+
.documentAs[TestDocument]
28292839
} yield assert(res)(Assertion.isEmpty)
28302840
}
28312841
} @@ around(

modules/library/src/main/scala/zio/elasticsearch/query/ElasticIntervalRule.scala

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ private[elasticsearch] final case class IntervalAllOf[S](
6565

6666
def orderedOn: IntervalAllOf[S] = copy(ordered = Some(true))
6767

68-
def orderedOff: IntervalAllOf[S] = copy(ordered = Some(false))
69-
7068
private[elasticsearch] def toJson: Json =
7169
Obj(
7270
"all_of" -> Obj(
@@ -87,7 +85,7 @@ private[elasticsearch] final case class IntervalAnyOf[S](
8785

8886
def filter(f: IntervalFilter[S]): IntervalAnyOf[S] = copy(filter = Some(f))
8987

90-
override private[elasticsearch] def toJson: Json =
88+
private[elasticsearch] def toJson: Json =
9189
Obj(
9290
"any_of" -> Obj(
9391
Chunk(
@@ -138,15 +136,15 @@ private[elasticsearch] final case class IntervalFuzzy[S](
138136

139137
def analyzer(value: String): IntervalFuzzy[S] = copy(analyzer = Some(value))
140138

141-
def useField(field: Field[_, _]): IntervalFuzzy[S] = copy(useField = Some(field.name))
142-
143-
def useField(field: String): IntervalFuzzy[S] = copy(useField = Some(field))
144-
145139
def prefixLength(length: Int): IntervalFuzzy[S] = copy(prefixLength = Some(length))
146140

141+
def transpositionsDisabled: IntervalFuzzy[S] = copy(transpositions = Some(false))
142+
147143
def transpositionsEnabled: IntervalFuzzy[S] = copy(transpositions = Some(true))
148144

149-
def transpositionsDisabled: IntervalFuzzy[S] = copy(transpositions = Some(false))
145+
def useField(field: Field[_, _]): IntervalFuzzy[S] = copy(useField = Some(field.name))
146+
147+
def useField(field: String): IntervalFuzzy[S] = copy(useField = Some(field))
150148

151149
private[elasticsearch] def toJson: Json =
152150
Obj(
@@ -182,13 +180,11 @@ private[elasticsearch] final case class IntervalMatch[S](
182180

183181
def orderedOn: IntervalMatch[S] = copy(ordered = Some(true))
184182

185-
def orderedOff: IntervalMatch[S] = copy(ordered = Some(false))
186-
187183
def useField(field: Field[_, _]): IntervalMatch[S] = copy(useField = Some(field.name))
188184

189185
def useField(field: String): IntervalMatch[S] = copy(useField = Some(field))
190186

191-
override private[elasticsearch] def toJson: Json =
187+
private[elasticsearch] def toJson: Json =
192188
Obj(
193189
"match" -> Obj(
194190
Chunk(
@@ -217,7 +213,7 @@ private[elasticsearch] final case class IntervalPrefix[S](
217213

218214
def useField(field: String): IntervalPrefix[S] = copy(useField = Some(field))
219215

220-
override private[elasticsearch] def toJson: Json =
216+
private[elasticsearch] def toJson: Json =
221217
Obj(
222218
"prefix" -> Obj(
223219
Chunk(

modules/library/src/test/scala/zio/elasticsearch/ElasticIntervalQuerySpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object ElasticIntervalQuerySpec extends ZIOSpecDefault {
4646
after = Some(intervalMatch("after_term"))
4747
)
4848

49-
val intervalWithFilter: IntervalMatch[String] = intervalMatch("lambda works").orderedOff
49+
val intervalWithFilter: IntervalMatch[String] = intervalMatch("lambda works")
5050
.maxGaps(2)
5151
.analyzer("standard")
5252
.filter(filter)

website/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = {
2525
'overview/queries/elastic_query_geo_polygon',
2626
'overview/queries/elastic_query_has_child',
2727
'overview/queries/elastic_query_has_parent',
28-
'overview/queries/elastic_query_interval.md',
28+
'overview/queries/elastic_query_interval',
2929
'overview/queries/elastic_query_match',
3030
'overview/queries/elastic_query_match_all',
3131
'overview/queries/elastic_query_match_boolean_prefix',

0 commit comments

Comments
 (0)