VectorHit

One hit of a vector search: a document's root and its distance to the query vector. Readable while its result is open.

Properties

Link copied to clipboard
abstract val distance: Float

The distance from the query vector to the document's, under the store's metric (SPEC.md §11.3): smaller is closer. Never NaN; infinite when it is too large for a float, as a dot product of huge vectors can be.

Link copied to clipboard
abstract val docId: DocId

The document.

Link copied to clipboard
abstract val documentKey: String?

The key of the document in a store with CreationOptions.documentKey, looked up when first read; else null.

Link copied to clipboard
abstract val encodedSize: Long

Payload bytes that store the document, before compression, as SearchHit.encodedSize counts them.

Link copied to clipboard
open val node: NodeRef

The document's root, the node the hit stands for.

Link copied to clipboard
abstract val type: String?

The type of the document's root as the result's snapshot sees it, or null.

Functions

Link copied to clipboard
open fun readJsonAsString(maxChars: Int): String

The document as a JSON string; throws ResultTooLargeException if it has more than maxChars characters.

abstract fun readJsonAsString(format: JsonFormat, maxChars: Int): String

The document as a JSON string laid out in format; throws ResultTooLargeException if the text has more than maxChars characters, its whitespace included.

Link copied to clipboard
open fun writeJsonTo(out: OutputStream)

Writes the document as JSON (SPEC.md §5) with memory independent of its size. Doesn't close out.

abstract fun writeJsonTo(out: OutputStream, format: JsonFormat)

Writes the document as JSON laid out in format (SPEC.md §5.1) with memory independent of its size. Doesn't close out.