diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index dd1bef5..7c2eace 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -9,16 +9,18 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # Lets NuGet/login request a GitHub OIDC token. steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v6 with: dotnet-version: | + 10.0.x 9.0.x 8.0.x - 7.0.x - 6.0.x - name: Display dotnet version run: dotnet --version - name: Restore dependencies @@ -30,8 +32,23 @@ jobs: - name: Test run: dotnet test --no-build --configuration Release --verbosity normal working-directory: ./src + - name: Pack + run: dotnet pack ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj --configuration Release --no-build --output ../artifacts/packages + working-directory: ./src + - name: Upload packages + uses: actions/upload-artifact@v7 + with: + name: nuget-packages + path: artifacts/packages/ + # Exchange the OIDC token immediately before publishing for a short-lived API key. + # Requires a matching NuGet.org trusted publishing policy created by koculu. + - name: NuGet login + uses: NuGet/login@v1 + id: login + with: + user: koculu - name: Publish the package to nuget.org - run: dotnet nuget push ZoneTree.FullTextSearch/bin/Release/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json + # Pushing a .nupkg also pushes the .snupkg symbol package next to it. + run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate env: - NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} - working-directory: ./src + NUGET_API_KEY: ${{ steps.login.outputs.NUGET_API_KEY }} diff --git a/src/ZoneTree.FullTextSearch.UnitTests/HashedSearchEngineTests.cs b/src/ZoneTree.FullTextSearch.UnitTests/HashedSearchEngineTests.cs index 9cd767a..7c9ab4b 100644 --- a/src/ZoneTree.FullTextSearch.UnitTests/HashedSearchEngineTests.cs +++ b/src/ZoneTree.FullTextSearch.UnitTests/HashedSearchEngineTests.cs @@ -27,13 +27,14 @@ public void AddRecord_ShouldAddRecordToIndex() Assert.That(searchResult, Contains.Item(record)); } - [Test] - public void DeleteRecord_ShouldRemoveRecordFromIndex() + [TestCase(false)] + [TestCase(true)] + public void DeleteRecord_ShouldRemoveRecordFromIndex(bool useSecondaryIndex) { - var dataPath = "data/DeleteRecord_ShouldRemoveRecordFromIndex"; + var dataPath = $"data/DeleteRecord_ShouldRemoveRecordFromIndex_{useSecondaryIndex}"; if (Directory.Exists(dataPath)) Directory.Delete(dataPath, true); - using var searchEngine = new HashedSearchEngine(dataPath); + using var searchEngine = new HashedSearchEngine(dataPath, useSecondaryIndex: useSecondaryIndex); // Arrange int record = 1; diff --git a/src/ZoneTree.FullTextSearch/Directory.Build.props b/src/ZoneTree.FullTextSearch/Directory.Build.props index 8590155..8e1a56b 100644 --- a/src/ZoneTree.FullTextSearch/Directory.Build.props +++ b/src/ZoneTree.FullTextSearch/Directory.Build.props @@ -5,8 +5,8 @@ Ahmed Yasin Koculu ZoneTree.FullTextSearch ZoneTree.FullTextSearch - 1.0.9.0 - 1.0.9.0 + 1.1.0.0 + 1.1.0.0 Ahmed Yasin Koculu ZoneTree.FullTextSearch ZoneTree.FullTextSearch is an open-source library that extends ZoneTree to provide efficient full-text search capabilities. It offers a fast, embedded search engine suitable for applications that require high performance and do not rely on external databases. diff --git a/src/ZoneTree.FullTextSearch/Index/IndexOfTokenRecordPreviousToken.cs b/src/ZoneTree.FullTextSearch/Index/IndexOfTokenRecordPreviousToken.cs index f858476..d53c6bd 100644 --- a/src/ZoneTree.FullTextSearch/Index/IndexOfTokenRecordPreviousToken.cs +++ b/src/ZoneTree.FullTextSearch/Index/IndexOfTokenRecordPreviousToken.cs @@ -108,8 +108,11 @@ public IndexOfTokenRecordPreviousToken( if (tokenComparer == null) tokenComparer = ComponentsForKnownTypes.GetComparer(); var fileStreamProvider = advancedOptions?.FileStreamProvider; + // Composite keys support custom comparers, so no compatible Bloom-filter hasher can be assumed. + // Advanced factory configurators can supply a hasher and enable the filter explicitly. var factory1 = new ZoneTreeFactory, byte>(fileStreamProvider) .SetDataDirectory($"{dataPath}/index1") + .SetMutableSegmentBloomFilterBitsPerItem(0) .SetIsDeletedDelegate( (in CompositeKeyOfTokenRecordPrevious key, in byte value) => value == 1) .SetMarkValueDeletedDelegate((ref byte x) => x = 1) @@ -134,6 +137,7 @@ public IndexOfTokenRecordPreviousToken( { var factory2 = new ZoneTreeFactory, byte>(fileStreamProvider) .SetDataDirectory($"{dataPath}/index2") + .SetMutableSegmentBloomFilterBitsPerItem(0) .SetIsDeletedDelegate( (in CompositeKeyOfRecordToken key, in byte value) => value == 1) .SetMarkValueDeletedDelegate((ref byte x) => x = 1) diff --git a/src/ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj b/src/ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj index f70ea4f..5339258 100644 --- a/src/ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj +++ b/src/ZoneTree.FullTextSearch/ZoneTree.FullTextSearch.csproj @@ -34,11 +34,7 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - +