Knn

February 13, 2026 ยท View on GitHub

Object representing a k-nearest neighbor search query

Properties

NameTypeDescriptionNotes
var_fieldstrField to perform the k-nearest neighbor search on
kintThe number of nearest neighbors to return
queryKnnQuery[optional]
query_vectorList[float]The vector used as input for the KNN search[optional]
doc_idintThe docuemnt ID used as input for the KNN search[optional]
efintOptional parameter controlling the accuracy of the search[optional]
rescoreboolOptional parameter enabling KNN rescoring (disabled by default)[optional]
oversamplingfloatOptional parameter setting a factor by which k is multiplied when executing the KNN search[optional]
filterQueryFilter[optional]

Example

from manticoresearch.models.knn import Knn

# TODO update the JSON string below
json = "{}"
# create an instance of Knn from a JSON string
knn_instance = Knn.from_json(json)
# print the JSON string representation of the object
print(Knn.to_json())

# convert the object into a dict
knn_dict = knn_instance.to_dict()
# create an instance of Knn from a dict
knn_from_dict = Knn.from_dict(knn_dict)

[Back to Model list] [Back to API list] [Back to README]