Content types
Note Optimizely Graph .NET Source SDK is optimized for CMS 12. Learn more about the C# SDK for CMS 13C# SDK for CMS 13.
Content types define the structure of content you manage and query in Optimizely Graph. They let you specify content attributes and determine how they should be indexed or queried for flexible content management and retrieval to meet specific business needs.
Index types
The following code example uses index types to optimize how the SDK indexes data fields within a content type for search and query.
public class Cafe
{
public string Name { get; set; }
public DateTime Established { get; set; }
public Location Address { get; set; }
public Menu Menu { get; set; }
}
public class Location
{
public string City { get; set; }
public string State { get; set; }
public string Zipcode { get; set; }
public string Country { get; set; }
}
public class Menu
{
public Beverage Beverage { get; set; }
public Food Food { get; set; }
}
public class Beverage
{
public string Name { get; set; }
public double Price { get; set; }
public List<string> Sizes { get; set; }
}
public class Food
{
public string Name { get; set; }
public double Price { get; set; }
public bool IsAvailable { get; set; }
}These indexing options help you configure your content for faster retrievals and more precise queries.
- PropertyType – Indexes nested data objects within your content structure.
- Queryable – Supports filtering, ordering, and faceting by specific fields. On string fields, it supports the endsWith operator and substring matching with like. It does not support the match or contains operators.
- Searchable – Supports full-text and semantic search on vectorized fields, plus ordering and faceting. On string fields, it supports the match and contains operators, does not support the endsWith operator, and like matches the start of a token rather than a substring.
match, contains, endsWith, and like are string-filter operators, so the operator differences between the two indexing types apply only to string fields. Non-string fields, such as the DateTime and bool fields in the following example, accept the comparison operators for their own type whether indexed as Queryable or Searchable.
Searchable is not a superset of Queryable. The two indexing types accept different operators, and like matches differently on each. To learn which operators each indexing type accepts, go to Operators.
Configure content types
Map and configure your content for efficient indexing using the following code sample:
client.ConfigureContentType<Cafe>()
.Field(x => x.Name, IndexingType.Queryable)
.Field(x => x.Established, IndexingType.Searchable)
.Field(x => x.Address, IndexingType.PropertyType)
.Field(x => x.Menu, IndexingType.PropertyType);
client.ConfigurePropertyType<Location>()
.Field(x => x.City, IndexingType.Queryable)
.Field(x => x.State, IndexingType.Queryable)
.Field(x => x.Zipcode, IndexingType.Searchable)
.Field(x => x.Country, IndexingType.Searchable);
client.ConfigurePropertyType<Menu>()
.Field(x => x.Beverage, IndexingType.PropertyType)
.Field(x => x.Food, IndexingType.PropertyType);
client.ConfigurePropertyType<Beverage>()
.Field(x => x.Name, IndexingType.Queryable)
.Field(x => x.Price, IndexingType.Queryable)
.Field(x => x.Sizes, IndexingType.Searchable);
client.ConfigurePropertyType<Food>()
.Field(x => x.Name, IndexingType.Queryable)
.Field(x => x.Price, IndexingType.Queryable)
.Field(x => x.IsAvailable, IndexingType.Searchable);Set language
Before saving your content types, set your preferred language using client.AddLanguage, as shown in the following code sample:
client.AddLanguage("en");Save content types
With the initialized client, save your content types. The SDK manages the backend request construction and interacts with Optimizely Graph on your behalf.
await client.SaveTypesAsync();View types
After completing the previous steps, go to the interactive GraphiQL page to view and query your configured types. See Access the interactive GraphiQL pageAccess the interactive GraphiQL page for instructions.
Note Remember to add your singlekey to the query parameter to access the GraphiQL page.
Next steps
After configuring your content types, sync your data with Optimizely Graph for content management and retrieval. See Sync contentSync content for information on syncing content, creating unique identifiers, and pushing data.