Content types
How to create content types using the Optimizely Graph .NET Source SDK.
Content types in Optimizely Graph define the content structure you can manage and query within 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 various index types to optimize how data fields within a content type are indexed for search and query purposes. These indexing options help you configure your content for faster retrievals and more precise queries.
PropertyType
– Used for nested data objects within your content structure.Queryable
– Used for filtering, ordering, and faceting by specific fields with support for the "contains" operator. See Operators.Searchable
– Used for full-text and semantic search using vectorized fields with support for the "match" operator, ordering, and faceting. See Operators.
Configure content types
You can map and configure your content to be indexed efficiently 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.IsAvaiable, IndexingType.Searchable);
Set language
Before saving your content types, set your preferred language usingclient.AddLanguage
, like 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, you can go the interactive GraphiQL page to view and query your configured types. See Access the interactive GraphiQL page for instructions on accessing the page.
Note
Remember to add your
singlekey
to the query parameter to access the GraphiQL page.
Next steps
After configuring your content types using the Optimizely Graph .NET Source SDK, you can sync your data with Optimizely Graph for seamless content management and retrieval within Optimizely. See Sync content for information on syncing content, creating unique identifiers, and pushing data efficiently.
Updated 15 days ago