---
title: Coveo Related Query
slug: '3043'
canonical_url: https://docs.coveo.com/en/3043/
collection: coveo-for-sitecore-v5
source_format: adoc
---
# Coveo Related Query

> **Legacy feature**
>
> The Coveo Hive Framework is now in maintenance mode and is no longer recommended for new implementations.
>
> To build new search experiences, use one of Coveo's more modern, lightweight, and responsive libraries.
> To get started, see the [Build search](https://docs.coveo.com/en/2473.md) article.

Implements the [Coveo JavaScript Search Framework](https://docs.coveo.com/en/187.md) [Recommendation](https://coveo.github.io/search-ui/components/recommendation.html) component to get a result list related to the one executed in the main search interface.

The main purpose of the **{doctitle}** rendering is to execute a second query, slightly different from the current search interface query, which may take into account, or not, the current search interface filters in its [advanced query expression (`aq`)](https://docs.coveo.com/en/175.md) and the current search interface query expression in its [basic query expression (`q`)](https://docs.coveo.com/en/178.md).

## Usage notes

* The **{doctitle}** rendering always acts as a full-fledged search interface and requires a dedicated analytics component (see [Coveo for Sitecore Analytics](https://docs.coveo.com/en/2186.md)).

* When bound to a search interface through the `Main search interface` data source option, the **{doctitle}** rendering inherits the [**Sitecore Instance Filter** configurations set on that search interface](https://docs.coveo.com/en/3044/?c4scV5HiveType=tab-hive#data-source-options).
When not bound to a search interface, you can add [Sitecore Instance Filter](https://docs.coveo.com/en/2192.md) and [Query Filter](https://docs.coveo.com/en/3038.md) renderings in the `Recommendations Components` placeholder to apply filtering on your Sitecore instance items.

* {empty}

  --

[Available since Coveo for Sitecore 5.0.822.2]

--
+
The [Sitecore Instance Filter](https://docs.coveo.com/en/2192.md) rendering is now added automatically with the **{doctitle}** rendering.
This adds the new [`Filter results based on the current Sitecore context database` data source option](#data-source-options) which lets you control whether to add a filter on the current Sitecore context database in the [constant query expression (`cq`)](https://docs.coveo.com/en/179.md).
Prior to the October 30, 2020 release, related query recommendations were automatically filtered on the current Sitecore context database.

* You can [customize the CSS](https://docs.coveo.com/en/2342.md) associated with this rendering.

## Insertion location

+
<div>
<h3>Coveo Hive</h3>
  
The **Coveo Related Query** rendering is an Allowed Control in the following placeholder(s): `Coveo UI`, `Recommendations`.

  <video width="690" height="335" controls="">
  <source src="https://docs.coveo.com/en/assets/images/c4sc-v5/related-query-hive.mp4" type="video/mp4" />
  Your browser doesn't support the video tag.
</video>
  <div class="figure-caption">Example insertion sequence for the **Coveo Related Query** rendering.
  </div>
</div>
<div>
<h3>Coveo Hive SXA</h3>
  
Coveo for Sitecore SXA rendering insertion locations aren't limited by placeholder Allowed Controls. The **Coveo Related Query** rendering may therefore be inserted throughout the partial design, whether in Coveo for Sitecore or Sitecore placeholders.

  <video width="690" height="335" controls="">
  <source src="https://docs.coveo.com/en/assets/images/c4sc-v5/related-query-sxa.mp4" type="video/mp4" />
  Your browser doesn't support the video tag.
</video>
  <div class="figure-caption">Example insertion sequence for the **Coveo Related Query** rendering.
  </div>
</div>
+

## Data source options

The following table lists the available data source options for this rendering.

| Option name | Description |
|---|---|
| Main search interface | See the [mainSearchInterface](https://coveo.github.io/search-ui/components/recommendation.html#options.mainsearchinterface) component option. |
| Use the search interface current filters | Adds `advancedExpression` to the [optionsToUse](https://coveo.github.io/search-ui/components/recommendation.html#options.optionstouse) component option values. |
| Use the search interface current query | Adds `expression` to the [optionsToUse](https://coveo.github.io/search-ui/components/recommendation.html#options.optionstouse) component option values. |
| Title | The text to show in the header. |
| Hide if no results | See the [hideIfNoResults](https://coveo.github.io/search-ui/components/recommendation.html#options.hideifnoresults) component option. |
| {empty} -- [Available since Coveo for Sitecore 5.0.822.2] -- Filter results based on the current Sitecore context database | See the [Sitecore Instance Filter](https://docs.coveo.com/en/2192/?c4scV5HiveType=tab-hive#data-source-options) rendering data source options. |
| Filter results on the current context language | See the [Sitecore Instance Filter](https://docs.coveo.com/en/2192/?c4scV5HiveType=tab-hive#data-source-options) rendering data source options. |
| Filter results on the latest version | See the [Sitecore Instance Filter](https://docs.coveo.com/en/2192/?c4scV5HiveType=tab-hive#data-source-options) rendering data source options. |
| Results per page | See the [resultsPerPage](https://coveo.github.io/search-ui/components/searchinterface.html#options.resultsperpage) component option. |
| Excerpt length | See the [excerptLength](https://coveo.github.io/search-ui/components/searchinterface.html#options.excerptlength) component option. |
| Automatically trigger first query | See the [autoTriggerQuery](https://coveo.github.io/search-ui/components/searchinterface.html#options.autotriggerquery) component option. |
| Hide until first query | See the [hideUntilFirstQuery](https://coveo.github.io/search-ui/components/searchinterface.html#options.hideuntilfirstquery) component option. |
| Enable history | See the [`enableHistory`](https://coveo.github.io/search-ui/components/searchinterface.html#options.enablehistory) component option. |
| Custom CSS classes | See [Insert custom CSS](https://docs.coveo.com/en/2342.md). |
| Initialization file name | See [Custom initialization scripts](https://docs.coveo.com/en/2788.md). |
| DOM unique ID | {empty} -- Randomly generated HTML element ID. -- |
| Additional data attributes | {empty} -- Allows [use of the Coveo JavaScript Search Framework **Recommendation** component options](https://docs.coveo.com/en/2776.md) that aren't directly available in the data source. -- |

## Sample generated HTML and corresponding visual output

In the example below, the `Use the search interface current query` data source option is selected, and the `Use the search interface current filters` option isn't selected.

```html
<div id="coveoa061205e" class="CoveoRecommendation CoveoSearchInterface Coveostate
CoveoComponentState CoveoComponentOptions CoveoQueryController coveo-after-initialization
CoveoDebug" data-prebind-main-search-interface="mainSearchInterfaceSelector"
data-main-search-interface="#coveoC606340E" data-hide-if-no-results="false"
data-options-to-use="constantExpression,expression" data-results-per-page="5"
data-prebind-maximum-age="currentMaximumAge" data-title="Related Articles"
data-applied-prebind="true" data-maximum-age="0"
data-coveo-for-sitecore-event-registered="true">
```

![Related Query Example | Coveo for Sitecore 5](https://docs.coveo.com/en/assets/images/c4sc-v5/related-query-habitat-home-example.png)