Skip to content

Configure Search

⏱ 20 minutes intermediate

Visitors expect to find content quickly. A properly configured search surfaces relevant pages, files, and blocks based on visitor queries. Without search configuration, your site relies on navigation alone, which fails for large content libraries.

Optimizely offers two search approaches. Graph is the modern, GraphQL-based content delivery and search API. Search & Navigation is the legacy full-text search service for PaaS installations.

CriteriaGraphSearch & Navigation
PlatformSaaS and PaaSPaaS only
Query languageGraphQL.NET LINQ-style API
Content deliveryYes (headless)Search only
Recommended forNew projectsExisting PaaS sites
  1. Navigate to Settings > Content Graph in the admin interface.
  2. Copy your App Key and Secret from the Graph configuration panel.
  3. Verify connectivity by opening the GraphQL playground link provided.
  4. Run a test query to confirm content is indexed.
Test Graph query
graphql
{
  Content(
    where: { _fulltext: { match: "getting started" } }
    limit: 5
  ) {
    items {
      Name
      _fulltext
      Url
    }
    total
  }
}
  1. Verify that search results return your published content items.
  1. Install the Optimizely.Search.Navigation NuGet package.
  2. Add your service URL and API key to appsettings.json.
Search & Navigation configuration
json
{
  "Optimizely": {
    "Search": {
      "DefaultIndex": "my_site_index",
      "ServiceUrl": "https://api.search.optimizely.com",
      "ServiceApiKey": "your-api-key-here"
    }
  }
}
  1. Navigate to Admin > Search & Navigation > Overview.
  2. Click Re-index to build the initial search index.
  3. Verify by checking the index statistics. You should see content items counted.

Control which content types and properties appear in search results.

Exclude a content type from search
csharp
using Optimizely.Search;

[SearchConfiguration(IndexInDefaultSearch = false)]
public class InternalSettingsBlock : BlockData
{
    // This block will not appear in search results
}
  1. Add [SearchConfiguration] to content types you want to exclude.
  2. Rebuild the index after making changes.
  3. Verify by searching for content from the excluded type. It should not appear.
  1. Create a page type with a search query string property.
  2. In the controller or view, execute a search query against Graph or Search & Navigation.
  3. Render the results with title, excerpt, and link for each item.
  4. Verify by entering a search term. You should see matching results with links.
  1. Open the search administration panel.
  2. Add boosted properties to weight titles higher than body text.
  3. Configure synonyms so related terms return the same results.
  4. Add best bets to pin specific pages to specific search terms.
  5. Verify by searching for a boosted term. The promoted page should appear first.
IssueCauseFix
No search resultsIndex not builtRun a re-index from the admin panel
Stale resultsContent changed after last indexEnable scheduled re-indexing
Unexpected content in resultsContent type not excludedAdd [SearchConfiguration] attribute