ObjectExtensionsKnn(Object, String, String) Method

Perform a KNN search on the float vector attribute name="floatVectorAttributeName"/> (Manticore only).

Definition

Namespace: SphinxConnector.FluentApi.Util
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.4.0
C#
public static bool Knn(
	this Object document,
	string floatVectorAttributeName,
	string query
)

Parameters

document  Object
The document containing the float vector attribute.
floatVectorAttributeName  String
The name of the vector attribute containing vector data.
query  String
The search query.

Return Value

Boolean

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Example

C#
var results = await fulltextSession.Query<Document>().
                                    Match("Machine Learning").
                                    Where(x => x.Knn("embedding_vector", "Machine Learning")).
                                    Select(x => new
                                    {
                                        x.Id,
                                        Dist = Function.KnnDist()
                                    }).
                                    OrderBy(x => x.Dist).
                                    ToListAsync();

See Also