Search content in Optimizely Graph
Run full-text searches in Optimizely Graph, filter results, boost relevance, and track user clicks.
Early access previewThis content is an early access preview and may change before general availability. Use the thumbs up or down at the end of this article to share feedback and help shape the final release.
Use .SearchFor() to run full-text searches against indexed content in Optimizely Graph. You can search all text fields or target specific fields, boost relevance for certain fields, apply filters, and track which search results users click.
Combine it with .UsingFullText() to search all text fields, or .UsingField() to target specific fields and control relevance boosting.
Search across all fields
Use .UsingFullText() searches every indexed text field:
var result = await client
.QueryContent<BlogPostPage>()
.SearchFor("graph api")
.UsingFullText()
.GetAsContentAsync();Search a specific field
Use .UsingField() limits the search to one field:
var result = await client
.QueryContent<BlogPostPage>()
.SearchFor("sorting")
.UsingField(x => x.Title!)
.GetAsContentAsync();Boost relevance for specific fields
Pass a boost value to increase the importance of matches in specific fields. Higher numbers have more influence:
var result = await client
.QueryContent<BlogPostPage>()
.SearchFor("api")
.UsingField(x => x.Title!, boost: 3)
.UsingField(x => x.Tags!, boost: 1)
.GetAsContentAsync();
NoteMatches in the
Titlefield rank three times higher than matches inTags.
Combine search with filters
Chain .Where() to narrow search results by field values:
var result = await client
.QueryContent<BlogPostPage>()
.SearchFor("api")
.UsingFullText()
.Where(x => x.BlogCategory == "Tutorials")
.GetAsContentAsync();Enable click-through tracking
Add .Track() to your search query to record which results users click.
var result = await client
.QueryContent<BlogPostPage>()
.SearchFor("api")
.UsingFullText()
.Track()
.GetAsContentAsync();
Note
.Track()only works when combined with.SearchFor(). See Track search result clicks in C# SDK for the full setup.
Updated 13 days ago
