Add SQL Server full-text search provider#37
Open
mhelleborg wants to merge 2 commits into
Open
Conversation
Implement SearchLite.SqlServer mirroring the Postgres/Sqlite providers: - SearchIndex<T>: full ISearchIndex<T> surface backed by Microsoft.Data.SqlClient, storing each index as a table (id, document NVARCHAR(MAX) JSON, search_text, last_updated). Full-text search via a full-text catalog + index over search_text, queried with FREETEXTTABLE and using its RANK as the relevance score. MERGE-based upserts, JSON_VALUE ordering, OFFSET/FETCH paging. - WhereClauseBuilder<T>: translates every FilterNode<T> Operator case to JSON_VALUE / OPENJSON predicates (CollectionContains via OPENJSON, ordering via JSON_VALUE), mirroring the SQLite json_extract/json_each approach. - SearchManager + ServiceCollectionExtensions matching the existing providers. - Tests/SearchLite.SqlServer.Tests: Testcontainers.MsSql fixture, concrete IndexTests subclass of the shared abstract suite, plus TableNameTests and WhereClauseTests. - Central package management: Microsoft.Data.SqlClient, Testcontainers.MsSql and Microsoft.Extensions.DependencyInjection.Abstractions added to Directory.Packages.props. - Both projects registered in SearchLite.sln. Note: the stock mcr.microsoft.com/mssql/server image does not ship Full-Text Search, so catalog/index creation is best-effort and full-text integration tests need a full-text-enabled image. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHZB8AqzqRcBEuzRurzJFf
# Conflicts: # SearchLite.sln
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the SQL Server provider — issue #24, part of the multi-provider epic #23. Mirrors the existing Postgres/SQLite providers and plugs into the shared
SearchLite.Conformancesuite.What's here
Source/SearchLite.SqlServer—SearchManager+SearchIndex<T>onMicrosoft.Data.SqlClient. Each index is a table (id NVARCHAR(450)PK,document NVARCHAR(MAX)JSON,search_text NVARCHAR(MAX),last_updated DATETIME2). Full implementation of theISearchIndex<T>surface withMERGEupserts,JSON_VALUEordering, andOFFSET/FETCHpaging.search_text, queried viaFREETEXTTABLEusing itsRANKas the relevance score.WhereClauseBuilder<T>translates everyFilterNode<T>OperatorintoJSON_VALUE/OPENJSONpredicates (collection membership viaOPENJSON … EXISTS, case-sensitive matching via aCS_AScollation), mirroring SQLite'sjson_extract/json_eachidiom.Tests/SearchLite.SqlServer.Tests— concrete subclass of the shared conformance suite via aTestcontainers.MsSqlfixture, plusTableNameTestsandWhereClauseTests.Microsoft.Data.SqlClient,Testcontainers.MsSql, andMicrosoft.Extensions.DependencyInjection.AbstractionstoDirectory.Packages.props(the DI abstractions aren't transitively provided byMicrosoft.Data.SqlClient, unlike Npgsql).Verification
WhereClauseTests+TableNameTests) pass.SearchLite.SqlServer.Testsand runs it on its own runner.The standard
mcr.microsoft.com/mssql/serverimage does not ship the SQL Server Full-Text Search component, soCREATE FULLTEXT CATALOG/INDEXinEnsureTableExistsAsyncis best-effort (wrapped in try/catch) andFREETEXTTABLEqueries will fail on the stockTestcontainers.MsSqlimage. Running the full conformance suite needs a full-text-enabled image (a custom imageFROMthe base server with the full-text feature). TheFREETEXTTABLERANKscoring and theMinScorethresholds in the shared suite are therefore not yet validated end-to-end against a live server — that's the main follow-up before this is production-ready.🤖 Generated with Claude Code
Generated by Claude Code