You can use Rules to raise some results over others, or put one result or banner at the top of the results.

Promoting a single item

Use Case

A book store wants to recommend a Harry Potter Box Set whenever the words Harry Potter form part of a search.

Rule

If query=Harry Potter then promote Harry Potter Box Set

API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// turn json into an array
$rule = array(
  'objectID' => 'promote-harry-potter-box-set',
  'condition' => array(
    'pattern' => 'Harry Potter',
    'anchoring' => 'contains'
  ),
  'consequence' => array(
    'promote' => array(
        'objectID' => 'HP-12345',
        'position': 0 // objectID 'HP-12345' ==> Harry Potter Box Set
    )
  )
);

// push rule to index
$index->saveRule($rule);

Dashboard

Qr harry potter

Promoting the newest release

Use Case

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 telling the engine that whenever iPhone is searched for, place the newest version at the top, but for the rest of the same brand phones, continue sorting by most-sold.

Rule

If query = iphone then promote newest iphone release

API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// turn json into an array
$rule = array(
  'objectID' => 'Promote iPhone X',
  'condition' => array(
    'pattern' => 'iPhone',
    'anchoring' => 'contains'
  ),
  'consequence' => array(
    'promote' => array(
      'objectID' => 'iPhone-12345',
      'position' => 0 // objectID 'iPhone-12345' ==> iPhone X (newest release)
    )
  )
);

// push Rule to index
$index->saveRule($rule);

Dashboard

Qr iphone x

Promoting some results over others

Note: This only applies to Enterprise plans.

Use Case

Tomato: A simple search, but one that may never return the fruit (or vegetable) because too many Tomato Soup brands are selling better than cherry tomatoes.

Rule

If query=tomato then put fruits higher than the rest

API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// turn json into an array
$rule = array(
  'objectID' => 'tomato fruit',
  'condition' => array(
    'pattern' => 'tomato',
    'anchoring' => 'contains'
  ),
  'consequence' => array(
    'optionalFilters' => 'food_group:fruit'
  )
);

// push Rule to index
$index->saveRule($rule);

Dashboard

Qr tomato

Did you find this page helpful?