Skip to content

.Net: Add provider-specific search parameters to Bing/Google connectors#13580

Open
alzarei wants to merge 5 commits intomicrosoft:feature-text-search-linqfrom
alzarei:address-roji-review-feedback
Open

.Net: Add provider-specific search parameters to Bing/Google connectors#13580
alzarei wants to merge 5 commits intomicrosoft:feature-text-search-linqfrom
alzarei:address-roji-review-feedback

Conversation

@alzarei
Copy link

@alzarei alzarei commented Feb 23, 2026

.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 on BingWebPage/GoogleWebPage, making them unreachable through the LINQ filter system. The only way to set them was via the deprecated TextSearchFilter.

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 defaults
  • GoogleTextSearchOptions: 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 via HashSet<string>)
  • BraveTextSearchOptions.cs: Fixed doc comment that incorrectly said "Bing" instead of "Brave"
  • 14 new unit tests (8 Bing, 6 Google)

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the SK Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • I didn't break anyone 😄

Validation

Check Result
Format (dotnet format --verify-no-changes) ✅ Pass
Build (dotnet build --configuration Release --warnaserror) ✅ Pass (0 warnings, 0 errors)
Unit tests (SemanticKernel.UnitTests) ✅ 1606/1606 passed
AOT publish (net10.0) ✅ Pass

…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.
@alzarei alzarei requested a review from a team as a code owner February 23, 2026 09:46
@moonbox3 moonbox3 added the .NET Issue or Pull requests regarding .NET code label Feb 23, 2026
@alzarei alzarei mentioned this pull request Feb 23, 2026
4 tasks
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.
@alzarei alzarei force-pushed the address-roji-review-feedback branch from a6dbce4 to 738a60e Compare February 25, 2026 11:47
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants