Skip to main content
To promote groups of results dynamically, see Smart Groups.
If typoTolerance is min or strict, promoted results might not appear if they contain more typos than the top results.

Promote a single items

For example, a book store wants to recommend a Harry Potter box set whenever the words “Harry Potter” form part of a search.

Rule

If the is Harry Potter, promote the Harry Potter box set.
By default, you can pin up to 300 per rule.

With the API

To run the code examples on this page, install the latest API client.
var response = await client.SaveRuleAsync(
  "INDEX_NAME",
  "promote-harry-potter-box-set",
  new Rule
  {
    ObjectID = "promote-harry-potter-box-set",
    Conditions = new List<Condition>
    {
      new Condition { Pattern = "Harry Potter", Anchoring = Enum.Parse<Anchoring>("Contains") },
    },
    Consequence = new Consequence
    {
      Promote = new List<Promote>
      {
        new Promote(new PromoteObjectID { ObjectID = "HP-12345", Position = 0 }),
      },
    },
  }
);
final response = await client.saveRule(
  indexName: "INDEX_NAME",
  objectID: "promote-harry-potter-box-set",
  rule: Rule(
    objectID: "promote-harry-potter-box-set",
    conditions: [
      Condition(
        pattern: "Harry Potter",
        anchoring: Anchoring.fromJson("contains"),
      ),
    ],
    consequence: Consequence(
      promote: [
        PromoteObjectID(
          objectID: "HP-12345",
          position: 0,
        ),
      ],
    ),
  ),
);
response, err := client.SaveRule(client.NewApiSaveRuleRequest(
  "INDEX_NAME", "promote-harry-potter-box-set",
  search.NewEmptyRule().SetObjectID("promote-harry-potter-box-set").SetConditions(
    []search.Condition{*search.NewEmptyCondition().SetPattern("Harry Potter").SetAnchoring(search.Anchoring("contains"))}).SetConsequence(
    search.NewEmptyConsequence().SetPromote(
      []search.Promote{*search.PromoteObjectIDAsPromote(
        search.NewEmptyPromoteObjectID().SetObjectID("HP-12345").SetPosition(0))}))))
if err != nil {
  // handle the eventual error
  panic(err)
}
UpdatedAtResponse response = client.saveRule(
  "INDEX_NAME",
  "promote-harry-potter-box-set",
  new Rule()
    .setObjectID("promote-harry-potter-box-set")
    .setConditions(Arrays.asList(new Condition().setPattern("Harry Potter").setAnchoring(Anchoring.CONTAINS)))
    .setConsequence(new Consequence().setPromote(Arrays.asList(new PromoteObjectID().setObjectID("HP-12345").setPosition(0))))
);
const response = await client.saveRule({
  indexName: 'indexName',
  objectID: 'promote-harry-potter-box-set',
  rule: {
    objectID: 'promote-harry-potter-box-set',
    conditions: [{ pattern: 'Harry Potter', anchoring: 'contains' }],
    consequence: { promote: [{ objectID: 'HP-12345', position: 0 }] },
  },
});
var response =
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "promote-harry-potter-box-set",
    rule =
      Rule(
        objectID = "promote-harry-potter-box-set",
        conditions =
          listOf(
            Condition(
              pattern = "Harry Potter",
              anchoring = Anchoring.entries.first { it.value == "contains" },
            )
          ),
        consequence =
          Consequence(promote = listOf(PromoteObjectID(objectID = "HP-12345", position = 0))),
      ),
  )
$response = $client->saveRule(
    'INDEX_NAME',
    'promote-harry-potter-box-set',
    ['objectID' => 'promote-harry-potter-box-set',
        'conditions' => [
            ['pattern' => 'Harry Potter',
                'anchoring' => 'contains',
            ],
        ],
        'consequence' => ['promote' => [
            ['objectID' => 'HP-12345',
                'position' => 0,
            ],
        ],
        ],
    ],
);
response = client.save_rule(
    index_name="INDEX_NAME",
    object_id="promote-harry-potter-box-set",
    rule={
        "objectID": "promote-harry-potter-box-set",
        "conditions": [
            {
                "pattern": "Harry Potter",
                "anchoring": "contains",
            },
        ],
        "consequence": {
            "promote": [
                {
                    "objectID": "HP-12345",
                    "position": 0,
                },
            ],
        },
    },
)
response = client.save_rule(
  "INDEX_NAME",
  "promote-harry-potter-box-set",
  Algolia::Search::Rule.new(
    algolia_object_id: "promote-harry-potter-box-set",
    conditions: [Algolia::Search::Condition.new(pattern: "Harry Potter", anchoring: "contains")],
    consequence: Algolia::Search::Consequence.new(
      promote: [Algolia::Search::PromoteObjectID.new(algolia_object_id: "HP-12345", position: 0)]
    )
  )
)
val response = Await.result(
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "promote-harry-potter-box-set",
    rule = Rule(
      objectID = "promote-harry-potter-box-set",
      conditions = Some(
        Seq(
          Condition(
            pattern = Some("Harry Potter"),
            anchoring = Some(Anchoring.withName("contains"))
          )
        )
      ),
      consequence = Consequence(
        promote = Some(
          Seq(
            PromoteObjectID(
              objectID = "HP-12345",
              position = 0
            )
          )
        )
      )
    )
  ),
  Duration(100, "sec")
)
let response = try await client.saveRule(
    indexName: "INDEX_NAME",
    objectID: "promote-harry-potter-box-set",
    rule: Rule(
        objectID: "promote-harry-potter-box-set",
        conditions: [SearchCondition(pattern: "Harry Potter", anchoring: SearchAnchoring.contains)],
        consequence: SearchConsequence(promote: [SearchPromote.searchPromoteObjectID(SearchPromoteObjectID(
            objectID: "HP-12345",
            position: 0
        ))])
    )
)

With the Visual Editor

  1. Go to the Algolia dashboard and select your Algolia .
  2. On the left sidebar, select Search.
  3. Select your Algolia .
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Visual Editor.
  7. Under Conditions:
    1. Click Set query condition(s).
    2. In Your search, type Harry Potter and click Apply.
  8. Under Consequences:
    1. Click Pin items.
    2. In Pinned items, find and select the item you want to promote (for example, HP-12345) and click Apply.
  9. Review and Publish your rule.

With the Manual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Manual Editor.
  7. In the Condition(s) section, enter Harry Potter in the Query field.
  8. In the Consequence(s) section:
    1. Click Add consequence and select Pin an item.
    2. Find and select the item you want to promote. For example, HP-12345.
  9. Save your rule.

Promote the newest release

For example, you’ve placed “best-selling items” at the top of your search results by using custom ranking. But the newest release? Set up a rule that promotes the newest iPhone for searches containing iPhone, while keeping other phones sorted by most-sold.

Rule

If query is iphone, promote the newest iPhone release.

With the API

var response = await client.SaveRuleAsync(
  "INDEX_NAME",
  "Promote-iPhone-X",
  new Rule
  {
    ObjectID = "Promote-iPhone-X",
    Conditions = new List<Condition>
    {
      new Condition { Pattern = "iPhone", Anchoring = Enum.Parse<Anchoring>("Contains") },
    },
    Consequence = new Consequence
    {
      Promote = new List<Promote>
      {
        new Promote(new PromoteObjectID { ObjectID = "iPhone-12345", Position = 0 }),
      },
    },
  }
);
final response = await client.saveRule(
  indexName: "INDEX_NAME",
  objectID: "Promote-iPhone-X",
  rule: Rule(
    objectID: "Promote-iPhone-X",
    conditions: [
      Condition(
        pattern: "iPhone",
        anchoring: Anchoring.fromJson("contains"),
      ),
    ],
    consequence: Consequence(
      promote: [
        PromoteObjectID(
          objectID: "iPhone-12345",
          position: 0,
        ),
      ],
    ),
  ),
);
response, err := client.SaveRule(client.NewApiSaveRuleRequest(
  "INDEX_NAME", "Promote-iPhone-X",
  search.NewEmptyRule().SetObjectID("Promote-iPhone-X").SetConditions(
    []search.Condition{*search.NewEmptyCondition().SetPattern("iPhone").SetAnchoring(search.Anchoring("contains"))}).SetConsequence(
    search.NewEmptyConsequence().SetPromote(
      []search.Promote{*search.PromoteObjectIDAsPromote(
        search.NewEmptyPromoteObjectID().SetObjectID("iPhone-12345").SetPosition(0))}))))
if err != nil {
  // handle the eventual error
  panic(err)
}
UpdatedAtResponse response = client.saveRule(
  "INDEX_NAME",
  "Promote-iPhone-X",
  new Rule()
    .setObjectID("Promote-iPhone-X")
    .setConditions(Arrays.asList(new Condition().setPattern("iPhone").setAnchoring(Anchoring.CONTAINS)))
    .setConsequence(new Consequence().setPromote(Arrays.asList(new PromoteObjectID().setObjectID("iPhone-12345").setPosition(0))))
);
const response = await client.saveRule({
  indexName: 'indexName',
  objectID: 'Promote-iPhone-X',
  rule: {
    objectID: 'Promote-iPhone-X',
    conditions: [{ pattern: 'iPhone', anchoring: 'contains' }],
    consequence: { promote: [{ objectID: 'iPhone-12345', position: 0 }] },
  },
});
var response =
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "Promote-iPhone-X",
    rule =
      Rule(
        objectID = "Promote-iPhone-X",
        conditions =
          listOf(
            Condition(
              pattern = "iPhone",
              anchoring = Anchoring.entries.first { it.value == "contains" },
            )
          ),
        consequence =
          Consequence(
            promote = listOf(PromoteObjectID(objectID = "iPhone-12345", position = 0))
          ),
      ),
  )
$response = $client->saveRule(
    'INDEX_NAME',
    'Promote-iPhone-X',
    ['objectID' => 'Promote-iPhone-X',
        'conditions' => [
            ['pattern' => 'iPhone',
                'anchoring' => 'contains',
            ],
        ],
        'consequence' => ['promote' => [
            ['objectID' => 'iPhone-12345',
                'position' => 0,
            ],
        ],
        ],
    ],
);
response = client.save_rule(
    index_name="INDEX_NAME",
    object_id="Promote-iPhone-X",
    rule={
        "objectID": "Promote-iPhone-X",
        "conditions": [
            {
                "pattern": "iPhone",
                "anchoring": "contains",
            },
        ],
        "consequence": {
            "promote": [
                {
                    "objectID": "iPhone-12345",
                    "position": 0,
                },
            ],
        },
    },
)
response = client.save_rule(
  "INDEX_NAME",
  "Promote-iPhone-X",
  Algolia::Search::Rule.new(
    algolia_object_id: "Promote-iPhone-X",
    conditions: [Algolia::Search::Condition.new(pattern: "iPhone", anchoring: "contains")],
    consequence: Algolia::Search::Consequence.new(
      promote: [Algolia::Search::PromoteObjectID.new(algolia_object_id: "iPhone-12345", position: 0)]
    )
  )
)
val response = Await.result(
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "Promote-iPhone-X",
    rule = Rule(
      objectID = "Promote-iPhone-X",
      conditions = Some(
        Seq(
          Condition(
            pattern = Some("iPhone"),
            anchoring = Some(Anchoring.withName("contains"))
          )
        )
      ),
      consequence = Consequence(
        promote = Some(
          Seq(
            PromoteObjectID(
              objectID = "iPhone-12345",
              position = 0
            )
          )
        )
      )
    )
  ),
  Duration(100, "sec")
)
let response = try await client.saveRule(
    indexName: "INDEX_NAME",
    objectID: "Promote-iPhone-X",
    rule: Rule(
        objectID: "Promote-iPhone-X",
        conditions: [SearchCondition(pattern: "iPhone", anchoring: SearchAnchoring.contains)],
        consequence: SearchConsequence(promote: [SearchPromote.searchPromoteObjectID(SearchPromoteObjectID(
            objectID: "iPhone-12345",
            position: 0
        ))])
    )
)

With the Visual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Visual Editor.
  7. Under Conditions:
    1. Click Set query condition(s).
    2. In Your search, type iPhone and click Apply.
  8. Under Consequences:
    1. Click Pin item.
    2. In Pinned items, find and select the item you want to promote (for example, iPhone-12345) and then click Apply.
  9. Review and Publish your rule.

With the Manual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Manual Editor.
  7. In the Condition(s) section, enter iPhone in the Query field and change the drop-down from Is to Contains.
  8. In the Consequence(s) section:
    1. Click Add consequence and select Pin an item.
    2. Find and select the item you want to promote (for example, iPhone-12345).
  9. Save your rule.

Promote several results

For example, you’re running a promotion on the newest Apple products. Set up a rule that promotes the newest Apple releases at the top of results for searches containing apple.

Rule

If query is apple, promote the newest Apple releases.

With the API

var response = await client.SaveRuleAsync(
  "INDEX_NAME",
  "Promote-Apple-Newest",
  new Rule
  {
    ObjectID = "Promote-Apple-Newest",
    Conditions = new List<Condition>
    {
      new Condition { Pattern = "apple", Anchoring = Enum.Parse<Anchoring>("Is") },
    },
    Consequence = new Consequence
    {
      Promote = new List<Promote>
      {
        new Promote(
          new PromoteObjectIDs
          {
            ObjectIDs = new List<string> { "iPhone-12345", "watch-123" },
            Position = 0,
          }
        ),
      },
    },
  }
);
final response = await client.saveRule(
  indexName: "INDEX_NAME",
  objectID: "Promote-Apple-Newest",
  rule: Rule(
    objectID: "Promote-Apple-Newest",
    conditions: [
      Condition(
        pattern: "apple",
        anchoring: Anchoring.fromJson("is"),
      ),
    ],
    consequence: Consequence(
      promote: [
        PromoteObjectIDs(
          objectIDs: [
            "iPhone-12345",
            "watch-123",
          ],
          position: 0,
        ),
      ],
    ),
  ),
);
response, err := client.SaveRule(client.NewApiSaveRuleRequest(
  "INDEX_NAME", "Promote-Apple-Newest",
  search.NewEmptyRule().SetObjectID("Promote-Apple-Newest").SetConditions(
    []search.Condition{*search.NewEmptyCondition().SetPattern("apple").SetAnchoring(search.Anchoring("is"))}).SetConsequence(
    search.NewEmptyConsequence().SetPromote(
      []search.Promote{*search.PromoteObjectIDsAsPromote(
        search.NewEmptyPromoteObjectIDs().SetObjectIDs(
          []string{"iPhone-12345", "watch-123"}).SetPosition(0))}))))
if err != nil {
  // handle the eventual error
  panic(err)
}
UpdatedAtResponse response = client.saveRule(
  "INDEX_NAME",
  "Promote-Apple-Newest",
  new Rule()
    .setObjectID("Promote-Apple-Newest")
    .setConditions(Arrays.asList(new Condition().setPattern("apple").setAnchoring(Anchoring.IS)))
    .setConsequence(
      new Consequence().setPromote(
        Arrays.asList(new PromoteObjectIDs().setObjectIDs(Arrays.asList("iPhone-12345", "watch-123")).setPosition(0))
      )
    )
);
const response = await client.saveRule({
  indexName: 'indexName',
  objectID: 'Promote-Apple-Newest',
  rule: {
    objectID: 'Promote-Apple-Newest',
    conditions: [{ pattern: 'apple', anchoring: 'is' }],
    consequence: { promote: [{ objectIDs: ['iPhone-12345', 'watch-123'], position: 0 }] },
  },
});
var response =
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "Promote-Apple-Newest",
    rule =
      Rule(
        objectID = "Promote-Apple-Newest",
        conditions =
          listOf(
            Condition(
              pattern = "apple",
              anchoring = Anchoring.entries.first { it.value == "is" },
            )
          ),
        consequence =
          Consequence(
            promote =
              listOf(
                PromoteObjectIDs(objectIDs = listOf("iPhone-12345", "watch-123"), position = 0)
              )
          ),
      ),
  )
$response = $client->saveRule(
    'INDEX_NAME',
    'Promote-Apple-Newest',
    ['objectID' => 'Promote-Apple-Newest',
        'conditions' => [
            ['pattern' => 'apple',
                'anchoring' => 'is',
            ],
        ],
        'consequence' => ['promote' => [
            ['objectIDs' => [
                'iPhone-12345',

                'watch-123',
            ],
                'position' => 0,
            ],
        ],
        ],
    ],
);
response = client.save_rule(
    index_name="INDEX_NAME",
    object_id="Promote-Apple-Newest",
    rule={
        "objectID": "Promote-Apple-Newest",
        "conditions": [
            {
                "pattern": "apple",
                "anchoring": "is",
            },
        ],
        "consequence": {
            "promote": [
                {
                    "objectIDs": [
                        "iPhone-12345",
                        "watch-123",
                    ],
                    "position": 0,
                },
            ],
        },
    },
)
response = client.save_rule(
  "INDEX_NAME",
  "Promote-Apple-Newest",
  Algolia::Search::Rule.new(
    algolia_object_id: "Promote-Apple-Newest",
    conditions: [Algolia::Search::Condition.new(pattern: "apple", anchoring: "is")],
    consequence: Algolia::Search::Consequence.new(
      promote: [Algolia::Search::PromoteObjectIDs.new(object_ids: ["iPhone-12345", "watch-123"], position: 0)]
    )
  )
)
val response = Await.result(
  client.saveRule(
    indexName = "INDEX_NAME",
    objectID = "Promote-Apple-Newest",
    rule = Rule(
      objectID = "Promote-Apple-Newest",
      conditions = Some(
        Seq(
          Condition(
            pattern = Some("apple"),
            anchoring = Some(Anchoring.withName("is"))
          )
        )
      ),
      consequence = Consequence(
        promote = Some(
          Seq(
            PromoteObjectIDs(
              objectIDs = Seq("iPhone-12345", "watch-123"),
              position = 0
            )
          )
        )
      )
    )
  ),
  Duration(100, "sec")
)
let response = try await client.saveRule(
    indexName: "INDEX_NAME",
    objectID: "Promote-Apple-Newest",
    rule: Rule(
        objectID: "Promote-Apple-Newest",
        conditions: [SearchCondition(pattern: "apple", anchoring: SearchAnchoring.`is`)],
        consequence: SearchConsequence(promote: [SearchPromote.searchPromoteObjectIDs(SearchPromoteObjectIDs(
            objectIDs: ["iPhone-12345", "watch-123"],
            position: 0
        ))])
    )
)

With the Visual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Visual Editor.
  7. Under Conditions:
    1. Click Set query condition(s).
    2. In Your search, type apple and click Apply.
  8. Under Consequences:
    1. Click Pin items.
    2. Click Pin multiple items.
    3. One per line, enter the object IDs of the items you want to pin, for example, iPhone-12345 and watch-123, in the input field and then click Pin items.
    4. Click Apply.
  9. Review and Publish your rule.
You can’t promote more than one item with the Manual Editor.

Promote results matching active filters

For example, you only want to promote items if they match a user’s active , such as stock availability, color, or category. This prevents irrelevant items such as out-of-stock products from appearing.

Rule

Create a rule with a consequence that pins the item only if it matches active filters.

With the API

To pin an item only if it matches active filters, set filterPromotes to true in the rule’s consequence.
namespace Algolia;

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json;
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

class EnableFilterPromote
{
  async Task Main(string[] args)
  {
    var condition = new Condition { Anchoring = Anchoring.Is, Pattern = "{facet:brand}" };

    var consequence = new Consequence { FilterPromotes = true };

    var rule = new Rule
    {
      ObjectID = "rule_with_filterPromotes",
      Conditions = [condition],
      Consequence = consequence,
    };
  }
}

import 'package:algolia_client_search/algolia_client_search.dart';

void enableFilterPromote() async {
  final condition = Condition(
    pattern: "{facet:brand}",
    anchoring: Anchoring.is_,
  );

  final consequence = Consequence(filterPromotes: true);

  // ignore: unused_local_variable
  final rule = Rule(
      objectID: "rule_with_filterPromotes",
      conditions: [condition],
      consequence: consequence);
}

package main

import (
	"fmt"

	"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
)

func enableFilterPromote() {
	condition := search.NewCondition().
		SetPattern("{facet:brand}").
		SetAnchoring(search.ANCHORING_IS)

	rule := search.NewRule(
		"rule_with_filterPromotes",
		*search.NewConsequence().SetFilterPromotes(true),
	).SetEnabled(true).SetConditions([]search.Condition{*condition})

	fmt.Printf("Rule: %#v\n", rule)
}

package com.algolia;

import com.algolia.config.*;
import com.algolia.model.search.*;
import java.util.List;

public class enableFilterPromote {

  public static void main(String[] args) throws Exception {
    Condition condition = new Condition().setAnchoring(Anchoring.IS).setPattern("{facet:brand}");

    Consequence consequence = new Consequence().setFilterPromotes(true);

    Rule rule = new Rule().setObjectID("rule_with_filterPromotes").setConditions(List.of(condition)).setConsequence(consequence);
  }
}

import type { Condition, Consequence } from 'algoliasearch';

const condition: Condition = {
  anchoring: 'is',
  pattern: '{facet:brand}',
};

const consequence: Consequence = {
  filterPromotes: true,
};

import com.algolia.client.configuration.*
import com.algolia.client.extensions.*
import com.algolia.client.model.search.*
import com.algolia.client.transport.*

suspend fun enableFilterPromote() {
  val condition = Condition(pattern = "{facet:brand}", anchoring = Anchoring.Is)

  val consequence = Consequence(filterPromotes = true)

  val rule =
    Rule(
      objectID = "rule_with_filterPromotes",
      conditions = listOf(condition),
      consequence = consequence,
    )
}

<?php

require __DIR__.'/../vendor/autoload.php';

use Algolia\AlgoliaSearch\Model\Search\Anchoring;
use Algolia\AlgoliaSearch\Model\Search\Condition;
use Algolia\AlgoliaSearch\Model\Search\Consequence;
use Algolia\AlgoliaSearch\Model\Search\Rule;

$condition = (new Condition())
    ->setAnchoring((new Anchoring())::IS)
    ->setPattern('{facet:brand}')
;

$consequence = (new Consequence())
    ->setFilterPromotes(true)
;

$rule = (new Rule())
    ->setObjectID('rule_with_filterPromotes')
    ->setConditions([$condition])
    ->setConsequence($consequence);

from algoliasearch.search.models.anchoring import Anchoring
from algoliasearch.search.models.condition import Condition
from algoliasearch.search.models.consequence import Consequence
from algoliasearch.search.models.rule import Rule


condition = Condition(
    anchoring=Anchoring.IS,
    pattern="{facet:brand}",
)

consequence = Consequence(
    filter_promotes=True,
)

rule = Rule(
    enabled=True,
    object_id="rule_with_filterPromotes",
    conditions=[condition],
    consequence=consequence,
)

condition = Algolia::Search::Condition.new(
  anchoring: Algolia::Search::Anchoring::IS,
  pattern: "{facet:brand}"
)

consequence = Algolia::Search::Consequence.new(
  filter_promotes: true
)

rule = Algolia::Search::Rule.new(
  enabled: true,
  object_id: "rule_with_filterPromotes",
  conditions: [condition],
  consequence: consequence
)

import scala.concurrent.ExecutionContext.Implicits.global

import algoliasearch.api.SearchClient
import algoliasearch.config.*
import algoliasearch.extension.SearchClientExtensions
import algoliasearch.search.{Anchoring, Condition, Consequence, Rule}

def enableFilterPromote(): Unit = {
  val condition = Condition(
    pattern = Some("{facet:brand}"),
    anchoring = Some(Anchoring.Is)
  )

  val consequence = Consequence(
    filterPromotes = Some(true)
  )

  val rule = Rule(
    objectID = "rule_with_filterPromotes",
    conditions = Some(Seq(condition)),
    consequence = consequence
  )
}

import Foundation
#if os(Linux) // For linux interop
    import FoundationNetworking
#endif

import AlgoliaCore
import AlgoliaSearch

func enableFilterPromote() async throws {
    let condition = SearchCondition(
        pattern: "{facet:brand}",
        anchoring: .is
    )

    let consequence = SearchConsequence(
        filterPromotes: true
    )

    let rule = Rule(objectID: "rule_with_filterPromotes", conditions: [condition], consequence: consequence)
    print(rule)
}

With the Visual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Visual Editor.
  7. Under Conditions:
    1. Click Set query condition(s).
    2. In Your search, enter the item you want to promote (for example, shoes) and click Apply.
  8. Under Consequences:
    1. Click Pin items.
    2. In Pinned items, find and select the item you want to promote.
    3. Keep the checkbox Pinned items must match active filters to be displayed selected and click Apply.
  9. Review and Publish your rule.

With the Manual Editor

  1. Go to the Algolia dashboard and select your Algolia application.
  2. On the left sidebar, select Search.
  3. Select your Algolia index.
  4. Select Rules from the left sidebar.
  5. Select Create your first Rule or New rule.
  6. Click Manual Editor.
  7. In the Condition(s) section, enter the query (for example, shoes) in the Query field.
  8. In the Consequence(s) section:
    1. Click Add consequence and select Pin an item.
    2. Find and select the item you want to promote (for example, brogue-12345).
  9. In the Additional settings section, keep the checkbox Pinned items must match active filters to be displayed selected.
  10. Save your rule.
Last modified on May 19, 2026