.Net: Add provider-specific search parameters to Bing/Google connectors#13580
Open
alzarei wants to merge 5 commits intomicrosoft:feature-text-search-linqfrom
Open
.Net: Add provider-specific search parameters to Bing/Google connectors#13580alzarei wants to merge 5 commits intomicrosoft:feature-text-search-linqfrom
alzarei wants to merge 5 commits intomicrosoft:feature-text-search-linqfrom
Conversation
…connectors Add request-side API parameters as instance-level defaults on BingTextSearchOptions and GoogleTextSearchOptions. These parameters (e.g., market, language, safe-search) control request behavior but have no representation in response models, making them unreachable via the LINQ filter system. BingTextSearchOptions: Market, Freshness, SafeSearch, CountryCode, SetLanguage, ResponseFilter, AnswerCount, Promote, TextDecorations, TextFormat. GoogleTextSearchOptions: CountryRestrict, DateRestrict, GeoLocation, InterfaceLanguage, LinkSite, LanguageRestrict, Rights, DuplicateContentFilter. Defaults are applied to every search request unless overridden by a per-request filter clause. Filter values always take precedence. Addresses Roji's Remark 3 on PR microsoft#13384.
Make LINQ expression processing the primary internal path with legacy TextSearchFilter as a thin shim on top. This inverts the dependency so that when the legacy ITextSearch interface is retired, removing the old path is just deleting ExtractFiltersFromLegacy() rather than rewriting the core logic. Changes across Bing, Google, Brave, and Tavily: - Replace TextSearchFilter intermediate with List<(string, object)> - Both LINQ (primary) and legacy (shim) paths produce this list - Core HTTP/JSON-building methods consume raw parameters directly - Add ExtractSearchParameters<TRecord> as LINQ entry point - Add ExtractFiltersFromLegacy as backward-compat shim with pragma - Remove ConvertToLegacyOptions, ConvertLinqExpressionTo*Filter, AnalyzeExpression, and all FilterClause-producing helpers - Replace with Process* methods that produce (FieldName, Value) directly Net reduction of ~175 lines by eliminating the intermediate conversion.
a6dbce4 to
738a60e
Compare
- Fix error message text: 'Unknown filter field name' -> 'Unknown equality filter clause field name' - Fix parameter name in ArgumentException: 'filters' -> 'searchOptions' - Fix ExtractFiltersFromLegacy: pass through null values so validation catches them - Update 5 test assertions from Assert.Equal to Assert.Contains for robustness
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.
.Net: Add provider-specific search parameters to Bing/Google connectors
Motivation and Context
Addresses @roji's feedback on PR #13384 (
feature-text-search-linq). Several Bing/Google API search parameters (mkt,freshness,safeSearch,cr,dateRestrict,gl, etc.) have no corresponding properties onBingWebPage/GoogleWebPage, making them unreachable through the LINQ filter system. The only way to set them was via the deprecatedTextSearchFilter.Issue: #10456
Description
BingTextSearchOptions: Added 10 request-side search parameters (Market,Freshness,SafeSearch,CountryCode,SetLanguage,ResponseFilter,AnswerCount,Promote,TextDecorations,TextFormat) as{ get; init; }instance-level defaultsGoogleTextSearchOptions: Added 8 request-side search parameters (CountryRestrict,DateRestrict,GeoLocation,InterfaceLanguage,LinkSite,LanguageRestrict,Rights,DuplicateContentFilter)BingTextSearch.cs/GoogleTextSearch.cs: Filter values take precedence over defaults (tracked viaHashSet<string>)BraveTextSearchOptions.cs: Fixed doc comment that incorrectly said "Bing" instead of "Brave"Contribution Checklist
Validation
dotnet format --verify-no-changes)dotnet build --configuration Release --warnaserror)SemanticKernel.UnitTests)