From d9eea7a58c2edf8fa0e5ad09aa83f6ff8a2e1400 Mon Sep 17 00:00:00 2001 From: Mark Duckworth <1124037+MarkDuckworth@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:10:22 -0600 Subject: [PATCH] another example --- .../Integration/VectorIntegrationTests.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Firestore/Swift/Tests/Integration/VectorIntegrationTests.swift b/Firestore/Swift/Tests/Integration/VectorIntegrationTests.swift index 0db7bce41c0..22740e8058d 100644 --- a/Firestore/Swift/Tests/Integration/VectorIntegrationTests.swift +++ b/Firestore/Swift/Tests/Integration/VectorIntegrationTests.swift @@ -34,6 +34,21 @@ class VectorIntegrationTests: FSTIntegrationTestCase { try await vectorQuery.getDocuments(source: VectorSource.server) } + func exampleFindNearestWithOptions() async throws { + let collection = collectionRef() + + let vectorQuery = collection.findNearest( + fieldPath: "embedding", + queryVector: [1.0, 2.0, 3.0], + limit: 10, + distanceMeasure: FirestoreDistanceMeasure.cosine, + options: FindNearestOptions().withDistanceResultFieldPath("distance") + .withDistanceThreshold(0.5) + ) + + try await vectorQuery.getDocuments(source: VectorSource.server) + } + func testWriteAndReadVectorEmbeddings() async throws { let collection = collectionRef()