-
Notifications
You must be signed in to change notification settings - Fork 691
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4d83b8
commit 0ff12c9
Showing
3 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
24 changes: 17 additions & 7 deletions
24
...s-core/src/test/scala/com/sksamuel/elastic4s/requests/mappings/DenseVectorFieldTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
package com.sksamuel.elastic4s.requests.mappings | ||
|
||
import com.sksamuel.elastic4s.ElasticApi | ||
import com.sksamuel.elastic4s.fields.DenseVectorField | ||
import com.sksamuel.elastic4s.handlers.fields.DenseVectorFieldBuilderFn | ||
import com.sksamuel.elastic4s.{ElasticApi, JacksonSupport} | ||
import com.sksamuel.elastic4s.fields.{DenseVectorField, DenseVectorIndexOptions, Hnsw} | ||
import com.sksamuel.elastic4s.handlers.fields.ElasticFieldBuilderFn | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class DenseVectorFieldTest extends AnyFlatSpec with Matchers with ElasticApi { | ||
|
||
private val field = DenseVectorField(name = "myfield", dims = 3) | ||
private val field = DenseVectorField( | ||
name = "myfield", | ||
dims = 3, | ||
indexOptions = Some(DenseVectorIndexOptions( | ||
`type` = Hnsw, | ||
m = Some(100), | ||
efConstruction = Some(100), | ||
confidenceInterval = Some(0.5d) | ||
)) | ||
) | ||
|
||
"A DenseVectorField" should "support dims property" in { | ||
DenseVectorFieldBuilderFn.build(field).string shouldBe | ||
"""{"type":"dense_vector","dims":3,"index":false,"similarity":"l2_norm"}""" | ||
"A DenseVectorField" should "support dims and index_options properties" in { | ||
val jsonStringValue = """{"type":"dense_vector","dims":3,"index":false,"similarity":"l2_norm","index_options":{"type":"hnsw","m":100,"ef_construction":100,"confidence_interval":0.5}}""" | ||
ElasticFieldBuilderFn(field).string shouldBe jsonStringValue | ||
ElasticFieldBuilderFn.construct(field.name, JacksonSupport.mapper.readValue[Map[String, Any]](jsonStringValue)) shouldBe (field) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters