
The search engine is sometimes underestimated, even though it is a critical component of an e-commerce site's user experience and directly affects customer satisfaction and conversion rates. Efficient search engine optimization is essential for e-commerce businesses looking to improve their site's search functionality, increase customer engagement, and drive sales growth.

The main benefit of personalizing search results is improved relevance, which leads to increased engagement. By defining the recipients for search query rules, you can offer targeted and personalized search results to specific customer groups. By analyzing customer behavior and purchase patterns, you can identify customers who share similar preferences and interests, enabling you to tailor search results to meet their unique needs and preferences.

In this use case, we are targeting heavy buyers who frequently purchase products from specific brands. By creating a segmentation that contains these customers, we can use query rules to suggest higher-priced items from the brands they already know and trust. 

## Prerequisites
---

- Enable [the AI Search Engine](/docs/settings/configuration/ai-engine-configuration/engine-configuration-for-search) for your workspace.
- Create and configure [search index](/docs/ai-hub/ai-search/create-index) and in the [filterable attributes](/docs/ai-hub/ai-search/define-attributes#filterable-attributes) add `Price` as a range attribute. 
- Implement transaction events using [SDK](/developers/web/transactions-sdk) or [API](https://developers.synerise.com/DataManagement/DataManagement.html#operation/CreateATransaction).
- [Implement AI search](https://developers.synerise.com/AISearch/AISearch.html) in any of your channels (mobile app, website, and so on).
- Create an RFM analysis thanks to which you will be able to define the segmentation of heavy buyers. You'll find a detailed process for creating the RFM analysis in [this use case](/use-cases/rfm-analysis).


  <div class="admonition admonition-note"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

  The heavy buyers segmentation shown in this use case is just an example. You can create it using your own rules according to your specific assumptions and business needs.

  </div></div></div>


## Process
---

In this use case, you will go through the following steps:
1. [Create segmentation of heavy buyers](/use-cases/segment-as-a-rule-condition#create-a-segmentation-of-heavy-buyers) based on RFM analysis. 
2. [Create an aggregate](/use-cases/segment-as-a-rule-condition#create-an-aggregate-for-average-customer-purchase-expenses) to calculate the average value a customer spent in the last 30 days.
3. [Create an aggregate](/use-cases/segment-as-a-rule-condition#create-aggregates-to-identify-top-bought-brands) to identify top-bought brands. 
4. [Create a query rule](/use-cases/segment-as-a-rule-condition#create-a-query-rule) based on the prepared segmentation and aggregates created in the previous steps. This rule will enforce showing heavy buyers higher-priced products from the top brands they most frequently purchase in search results.

## Create a segmentation of heavy buyers
---
In this part of the process, create a segmentation of heavy buyers based on the RFM segmentation you created earlier. 

1. Go to **Decision Hub > Segmentations > New segmentation**.
2. Enter the name of the segment.
3. Choose **Add condition** and find the RFM segmentation you created earlier. 
4. Select the **Equal** operator and in the right field enter the name of the sub-segment that defines the heavy buyers. In our case, we type - `Heavy Buyers`
5. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/heavy-buyers-rfm.png" alt="Aggregate settings"  class="full">
<figcaption>Segmentation settings</figcaption>
</figure> 

## Create an aggregate for average customer purchase expenses
---
In this section, create an aggregate that returns the average value of products purchased by an individual customer in the last 30 days.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**. 
2. Enter the name of the aggregate.
3. Click **Analyze profiles by** and select **Average**.  
4. From the **Choose event** dropdown list, select the `product.buy` event.
5. As the event parameter, select **$finalUnitPrice**. 
6. Define the period from which data will be analyzed. In our case it will be last 30 days.
7. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/average-product-price-aggregate.png" alt="Aggregate settings"  class="full">
<figcaption>Aggregate settings</figcaption>
</figure> 

## Create aggregates to identify top-bought brands
---
In this section, create an aggregate that returns the top-bought brands by an individual customer.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/behavioral-data-hub-icon.svg" alt="Behavioral Data Hub icon" class="icon"> **Behavioral Data Hub > Live Aggregates > Create aggregate**.
2. As the aggregate type, select **Profile**. 
2. Enter the name of the aggregate.
3. Click **Analyze profiles by** and select **Top**.  
4. From the **Choose event** dropdown list, select the **product.buy** event.
5. As the event parameter, select **brand**.
6. Define the period from which the aggregate will return products from the event. 
7. Save the aggregate.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/product.buy_brand.png" class="full" alt="Configuration of the aggregate">
<figcaption>Configuration of the aggregate</figcaption>
</figure>

## Create a query rule
---
In this part of the process, create a query rule for heavy buyers that will enforce showing to them higher-priced products from the top brands they most frequently purchase in search results.

1. Go to <img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/icons/ai-hub-icon.svg" alt="AI Hub icon" class="icon" > **AI Hub > Indexes**.
2. Select an index from the list.
3. Go to the **Rules** section. 
4. On the right side of the screen, click **Add rule**.
5. Name the rule. 
6. To define the audience group for the rule, in the **Audience** section, click **Change**.
    1. Choose the **Segments** tab and click **Add segments**.
    2. Find the segment of heavy buyers you created [earlier in the process](/use-cases/segment-as-a-rule-condition#create-a-segmentation-of-heavy-buyers) and apply that segment.
7. To adjust the query conditions, in the **Conditions** section, click **Define**.  
    1. Choose the **All queries** tab.
    2. Click **Apply**.
8. To define how the search engine reacts to the defined conditions, in the **Consequences** section, click **Define**.
    1. Click **Add consequence** and choose **Filter query results** from the dropdown list.
    2. From the **Attribute** dropdown list, choose `Price`.
    3. Choose the **More than** operator.
    4. In the left field, click the **#** icon and from the dropdown list, select **Aggregate**.
    5. From the list, choose [aggregate](/use-cases/segment-as-a-rule-condition#create-an-aggregate-for-average-customer-purchase-expenses) created earlier in the process. 
    6. Click **Add filter** and from the **Attribute** dropdown list, choose **Brand**.
    7. Choose the **In** operator.
    8. In the left field, click the **T** icon and from the dropdown list, select **Aggregate**.
    9. From the list, choose [aggregate](/use-cases/segment-as-a-rule-condition#create-aggregates-to-identify-top-bought-brands) created earlier in the process. 
    10. Enable the **Mark as elastic** option to make sure that the items you set will appear at the top of the search results. If you do not activate this option, search results will show only those products.
    11. Click **Apply**.
9. In the **Schedule** section, you can define when the query rule applies.
10. Click **Save & Publish**.

<figure>
<img src="/api/docs/image/54176ad07f146575310749eba44b7c2f42c1b327/use-cases/all-cases/_gfx/query-rules-with-segmentation.png" alt="Query rule settings"  class="full">
<figcaption>Query rule settings</figcaption>
</figure> 

## Check the use case set up on the Synerise Demo workspace
---

You can check the configuration directly in Synerise demo workspace:

- [Segmentation](https://app.synerise.com/analytics/segmentations/a8b2ed5c-c342-436f-a98e-eca642767926) of heavy buyers,
- [Aggregate](https://app.synerise.com/analytics/aggregates/869e7abf-f235-3614-af7c-69b22ad88175) with the average value a customer spent in the last 30 days,
- [Aggregate](https://app.synerise.com/analytics/aggregates/04a8575c-9c62-37bb-a4ee-c99238e38ba5) to identify top-bought brands,
- [Query rule settings](https://app.synerise.com/ai-v2/search/indices/afc98c53b968b4c47ff1e21e7219d4f41668083405/query-rules/15408).

If you’re our partner or client, you already have automatic access to the **Synerise Demo workspace (1590)**, where you can explore all the configured elements of this use case and copy them to your workspace.  

If you’re not a partner or client yet, we encourage you to fill out the contact [form](https://demo.synerise.com/request) to schedule a meeting with our representatives. They’ll be happy to show you how our demo works and discuss how you can apply this use case in your business. 

## Read more
---

- [Aggregates](/docs/analytics/aggregates)
- [AI Search](/docs/ai-hub/ai-search)
- [Segmentation](/docs/analytics/segmentations)






