Add Azure Cosmos DB (NoSQL) full-text search provider#38
Open
mhelleborg wants to merge 2 commits into
Open
Conversation
Implements SearchLite.CosmosDB mirroring the Postgres provider: - One Cosmos container per index, partition key /id, document stored as JSON under a "doc" envelope property alongside a denormalized "searchText" field that the container's full-text index policy targets. - Full-text search via FullTextContains + ORDER BY RANK FullTextScore (BM25) using the GA FTS APIs in Microsoft.Azure.Cosmos 3.61.0. - WhereClauseBuilder<T> translating every Operator case into parameterized Cosmos NoSQL WHERE clauses (ARRAY_CONTAINS for collection membership, CONTAINS/STARTSWITH/ENDSWITH for string ops, IS_DEFINED/IS_NULL for null semantics, IN for set membership), offset/limit pagination. - Test project reusing the shared abstract conformance suite via a Testcontainers Cosmos emulator fixture, plus container-naming and WhereClause unit tests (26 unit tests passing without infrastructure). 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 Azure Cosmos DB (NoSQL API) provider — issue #28, part of the multi-provider epic #23. Mirrors the Postgres provider's structure and plugs into the shared
SearchLite.Conformancesuite.What's here
Source/SearchLite.CosmosDB—SearchManager+SearchIndex<T>onMicrosoft.Azure.Cosmos3.61. Each logical index maps to one container in a single database (defaultsearchlite); the document is stored verbatim as JSON under adocenvelope alongside a denormalizedsearchText, withidand partition key both set to the document id (/idpartition key — cheap single-partition point ops).FullTextPolicy+ full-text index over/searchText; queries match withFullTextContainsand rank viaORDER BY RANK FullTextScore(...)(BM25).WhereClauseBuilder<T>translates everyOperatorinto parameterized Cosmos NoSQLWHEREclauses (c.doc["Field"]accessors,ARRAY_CONTAINSfor collection membership,CONTAINS/STARTSWITH/ENDSWITH+ case-insensitive variants,IS_DEFINED/IS_NULL,IN), withOFFSET/LIMITpaging.Tests/SearchLite.CosmosDB.Tests— concrete subclass of the shared conformance suite via a Testcontainers Cosmos emulator fixture, plus container-naming and Cosmos-SQL translation unit tests.Microsoft.Azure.CosmostoDirectory.Packages.props.Verification
SearchLite.CosmosDB.Tests.FullTextScoreonly insideORDER BY RANKand won't let it be projected intoSELECT. So ranking is correct (server-side BM25 viaORDER BY RANK), butSearchResult.Score/MaxScoreare a synthesized strictly-decreasing1/(1+rank), andMinScorefilters against that synthetic value — semantics differ from Postgrests_rank. (This is exactly the kind of cross-provider scoring divergence flagged in epic [Epic] Formalize the common search-provider interface for multi-backend support #23.)IncludePartialMatches), unicode handling, and the exact result counts the shared suite asserts are unverified and may need tuning once the emulator can run in CI.AzureCosmosDisableNewtonsoftJsonCheck(the SDK still resolves its own Newtonsoft at runtime).🤖 Generated with Claude Code
Generated by Claude Code