KnnFloatVectorQuery

open class KnnFloatVectorQuery(field: String, target: FloatArray, k: Int, filter: Query?, searchStrategy: KnnSearchStrategy) : AbstractKnnVectorQuery

Uses KnnVectorsReader.search to perform nearest neighbour search.

This query also allows for performing a kNN search subject to a filter. In this case, it first executes the filter for each leaf, then chooses a strategy dynamically:

  • If the filter cost is less than k, just execute an exact search

  • Otherwise run a kNN search subject to the filter

  • If the kNN search visits too many vectors without completing, stop and run an exact search

Constructors

Link copied to clipboard
constructor(field: String, target: FloatArray, k: Int, filter: Query?, searchStrategy: KnnSearchStrategy)
constructor(field: String, target: FloatArray, k: Int, filter: Query? = null)

Find the k nearest documents to the target vector according to the vectors in the given field. target vector.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val k: Int
Link copied to clipboard

Functions

Link copied to clipboard
open fun createWeight(searcher: IndexSearcher, scoreMode: ScoreMode, boost: Float): Weight

Expert: Constructs an appropriate Weight implementation for this query.

Link copied to clipboard
open operator override fun equals(o: Any?): Boolean

Override and implement query instance equivalence properly in a subclass. This is required so that QueryCache works properly.

Link copied to clipboard
open override fun hashCode(): Int

Override and implement query hash code properly in a subclass. This is required so that [ ] works properly.

Link copied to clipboard
open override fun rewrite(indexSearcher: IndexSearcher): Query

Expert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.

Link copied to clipboard
open override fun toString(field: String?): String

Prints a query to a string, with field assumed to be the default field and omitted.

open override fun toString(): String

Prints a query to a string.

Link copied to clipboard
open override fun visit(visitor: QueryVisitor)

Recurse through the query tree, visiting any child queries.