// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SaveRulesAsync(
"<YOUR_INDEX_NAME>",
new List<Rule>
{
new Rule
{
ObjectID = "a-rule-id",
Conditions = new List<Condition>
{
new Condition { Pattern = "smartphone", Anchoring = Enum.Parse<Anchoring>("Contains") },
},
Consequence = new Consequence
{
Params = new ConsequenceParams { Filters = "brand:apple" },
},
},
new Rule
{
ObjectID = "a-second-rule-id",
Conditions = new List<Condition>
{
new Condition { Pattern = "apple", Anchoring = Enum.Parse<Anchoring>("Contains") },
},
Consequence = new Consequence
{
Params = new ConsequenceParams { Filters = "brand:samsung" },
},
},
},
false,
true
);
// >LOG