Object ExtensionsKnn(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
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.4.0
C#
public static bool Knn(
this Object document,
string floatVectorAttributeName,
string query
)VB
<ExtensionAttribute>
Public Shared Function Knn (
document As Object,
floatVectorAttributeName As String,
query As String
) As BooleanParameters
- 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
BooleanUsage 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();