Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: ["1.32.27", "1.33.18", "1.34.20", "1.35.23", "1.36.21", "1.37.12", "1.38.4"]
version: ["1.32.27", "1.33.18", "1.34.20", "1.35.23", "1.36.23", "1.37.14", "1.38.9", "1.39.0"]
uses: ./.github/workflows/test-on-weaviate-version.yml
secrets: inherit
with:
Expand Down
78 changes: 78 additions & 0 deletions src/Weaviate.Client.Tests/Integration/TestQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,84 @@ await collection.Data.InsertMany(
Assert.Equal("apples are big", firstObject.BelongsToGroup);
}

/// <summary>
/// Tests that test bm 25 operator and cross matches tokens across properties
/// </summary>
[Fact]
public async Task Test_BM25_Operator_AndCross()
{
RequireVersion("1.38.8");

var collection = await CollectionFactory(
properties: [Property.Text("title"), Property.Text("body")],
vectorConfig: Configure.Vector(t => t.SelfProvided())
);

// Neither of splitAcross's properties holds both tokens, so only cross-property AND matches it.
var splitAcross = await collection.Data.Insert(
new { title = "banana", body = "split" },
cancellationToken: TestContext.Current.CancellationToken
);
var singleProperty = await collection.Data.Insert(
new { title = "banana split", body = "dessert" },
cancellationToken: TestContext.Current.CancellationToken
);
await collection.Data.Insert(
new { title = "banana", body = "bread" },
cancellationToken: TestContext.Current.CancellationToken
);

var andObjs = await collection.Query.BM25(
"banana split",
searchOperator: new BM25Operator.And(),
cancellationToken: TestContext.Current.CancellationToken
);
Assert.Equal(new List<Guid?> { singleProperty }, andObjs.Select(o => o.UUID).ToList());

var andCrossObjs = await collection.Query.BM25(
"banana split",
searchOperator: new BM25Operator.AndCross(),
cancellationToken: TestContext.Current.CancellationToken
);
var expected = new List<Guid?> { splitAcross, singleProperty };
expected.Sort();
Assert.Equal(expected, andCrossObjs.Select(o => o.UUID).OrderBy(x => x).ToList());
}

/// <summary>
/// Tests that test bm 25 operator and cross rejects mixed tokenization
/// </summary>
[Fact]
public async Task Test_BM25_Operator_AndCross_MixedTokenization_Errors()
{
RequireVersion("1.38.8");

var collection = await CollectionFactory(
properties:
[
Property.Text("title", tokenization: PropertyTokenization.Word),
Property.Text("code", tokenization: PropertyTokenization.Field),
],
vectorConfig: Configure.Vector(t => t.SelfProvided())
);

await collection.Data.Insert(
new { title = "banana split", code = "banana-split" },
cancellationToken: TestContext.Current.CancellationToken
);

var exception = await Assert.ThrowsAnyAsync<WeaviateException>(async () =>
await collection.Query.BM25(
"banana split",
searchFields: ["title", "code"],
searchOperator: new BM25Operator.AndCross(),
cancellationToken: TestContext.Current.CancellationToken
)
);
Assert.NotNull(exception.InnerException);
Assert.Contains("tokenization", exception.InnerException.Message);
}

/// <summary>
/// Tests that test collection generative fetch objects
/// </summary>
Expand Down
49 changes: 49 additions & 0 deletions src/Weaviate.Client.Tests/Integration/TestSearchHybrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,55 @@ await collection.Query.Hybrid(
Assert.Equal(expected, rest);
}

/// <summary>
/// Tests that test hybrid bm 25 operator and cross
/// </summary>
[Fact]
public async Task Test_Hybrid_BM25_Operator_AndCross()
{
RequireVersion("1.38.8");

var collection = await CollectionFactory(
properties: new[] { Property.Text("title"), Property.Text("body") },
vectorConfig: Configure.Vector(t => t.SelfProvided())
);

// Neither of splitAcross's properties holds both tokens, so only cross-property AND matches it.
var splitAcross = await collection.Data.Insert(
new { title = "banana", body = "split" },
vectors: new float[] { 1, 0, 0, 0 },
cancellationToken: TestContext.Current.CancellationToken
);
await collection.Data.Insert(
new { title = "banana", body = "bread" },
vectors: new float[] { 0, 1, 0, 0 },
cancellationToken: TestContext.Current.CancellationToken
);

var andObjs = (
await collection.Query.Hybrid(
"banana split",
vectors: null,
alpha: 0.0f,
bm25Operator: new BM25Operator.And(),
cancellationToken: TestContext.Current.CancellationToken
)
).ToList();
Assert.Empty(andObjs);

var andCrossObjs = (
await collection.Query.Hybrid(
"banana split",
vectors: null,
alpha: 0.0f,
bm25Operator: new BM25Operator.AndCross(),
cancellationToken: TestContext.Current.CancellationToken
)
).ToList();
Assert.Single(andCrossObjs);
Assert.Equal(splitAcross, andCrossObjs[0].UUID);
}

/// <summary>
/// Tests that test aggregate max vector distance
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/Weaviate.Client.Tests/Unit/Mocks/MockHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public static (
{
grpcClient.SetUseAlphaParam(true);
}
grpcClient.SetServerVersion(weaviateVersion);

var client = new WeaviateClient(grpcClient: grpcClient, meta: meta);

Expand Down
Loading
Loading