Using the Bing Text Search (Preview)
Warning
The Semantic Kernel Text Search functionality is in preview, and improvements that require breaking changes may still occur in limited circumstances before release.
Overview
The Bing Text Search implementation uses the Bing Web Search API to retrieve search results. You must provide your own Bing Search Api Key to use this component.
Limitations
Feature Area | Support |
---|---|
Search API | Bing Web Search API only. |
Supported filter clauses | Only "equal to" filter clauses are supported. |
Supported filter keys | The responseFilter query parameter and advanced search keywords are supported. |
Tip
Follow this link for more information on how to filter the answers that Bing returns. Follow this link for more information on using advanced search keywords
Getting started
The sample below shows how to create a BingTextSearch
and use it to perform a text search.
using Microsoft.SemanticKernel.Data;
using Microsoft.SemanticKernel.Plugins.Web.Bing;
// Create an ITextSearch instance using Bing search
var textSearch = new BingTextSearch(apiKey: "<Your Bing API Key>");
var query = "What is the Semantic Kernel?";
// Search and return results as a string items
KernelSearchResults<string> stringResults = await textSearch.SearchAsync(query, new() { Top = 4, Skip = 0 });
Console.WriteLine("--- String Results ---\n");
await foreach (string result in stringResults.Results)
{
Console.WriteLine(result);
}
// Search and return results as TextSearchResult items
KernelSearchResults<TextSearchResult> textResults = await textSearch.GetTextSearchResultsAsync(query, new() { Top = 4, Skip = 4 });
Console.WriteLine("\n--- Text Search Results ---\n");
await foreach (TextSearchResult result in textResults.Results)
{
Console.WriteLine($"Name: {result.Name}");
Console.WriteLine($"Value: {result.Value}");
Console.WriteLine($"Link: {result.Link}");
}
// Search and return s results as BingWebPage items
KernelSearchResults<object> fullResults = await textSearch.GetSearchResultsAsync(query, new() { Top = 4, Skip = 8 });
Console.WriteLine("\n--- Bing Web Page Results ---\n");
await foreach (BingWebPage result in fullResults.Results)
{
Console.WriteLine($"Name: {result.Name}");
Console.WriteLine($"Snippet: {result.Snippet}");
Console.WriteLine($"Url: {result.Url}");
Console.WriteLine($"DisplayUrl: {result.DisplayUrl}");
Console.WriteLine($"DateLastCrawled: {result.DateLastCrawled}");
}
Coming soon
More coming soon.
Coming soon
More coming soon.
Next steps
The following sections of the documentation show you how to:
- Create a plugin and use it for Retrieval Augmented Generation (RAG).
- Use text search together with function calling.
- Learn more about using vector stores for text search.