<!-- Source: https://docs.squirro.com/en/latest/technical/search/features/popular-query.html -->
# Popular Query Suggestions

Profiles: Project Creator, Search User

Squirro can suggest queries to the user that have been used in a previous search.

While typing in a query, the matching query suggestions are suggested to the user as autocompletion with the suggested queries ranked on popularity and relevance.

The more often a query was used, the higher the popularity score.

Search users will see this by default when they begin typing a query in the search bar. Project creators can tune the settings for the popular query suggestions.

> **Note**
>
> You must set up [Activity Tracking](../../admin/operations/activity-tracking.md#admin-operations-activity-tracking) to use the Popular Query Suggestions feature.

## Example

In the example shown below, the top two suggestions are popular queries. The next suggestions in the list are content-based [key phrase](../../data-processing/pipeline-steps/discover.md#pipeline-steps-discover-key-phrase) suggestions, followed by the suggestions for communities.

[![image1](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2677342693/2773581850.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2677342693/2773581850.png)

## Popular Query Setup

The diagram below depicts the conceptual data flow when a user enters a query:

[![image2](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2677342693/2677342734.png)](https://s3.amazonaws.com/download.squirro.net/docs/migrated-attachments/2677342693/2677342734.png)

1. _Frontend Service/activity_: Tracks users’ dashboard interactions, search queries, and their results.
2. _Elastic Activity Logs Index_: The _Log Shipper_ indexes log files from the file system into Elastic (Squirro project index) using the _Squirro Activity Log_ data source (see [Activity Tracking](../../admin/operations/activity-tracking.md#admin-operations-activity-tracking)).
3. _Update Manager_:

   1. Aggregates unique queries from the _Activity Logs Index_ (2)
   2. Maintains the customised Popular Queries Index that stores:

      query, context, trendiness.popularity
4. _Topic Service/typeahead_: Returns typeahead suggestions from the _Popular Query Index_

## Settings

### Server Configuration

Configure the following server-wide settings in the _Server_ space under _Configuration_:

|  |  |  |
| --- | --- | --- |
| **Name** | **Value** | **Description** |
| `topic.typeahead.popular.enabled` | `true` `false` Default: `true` | Enable or disable the popular query feature. - Requires that all activity tracking is correctly setup and configured, the facets are correctly mapped and the data is available in the monitoring project. |
| `topic.typeahead.popular.popular-query-idx` | `squirro_popular_queries-v1` (setting not meant to be changed; exists to be ready for future change) | Elesticsearch index that contains all unique queries, sorted by popularity and project. This is the input data for the _Typeahead Suggester_ (see figure above). |
| `topic.typeahead.popular.schedule-frequency` | `30` | Interval in seconds to run popular-query aggregation update task. |

### Project Configuration

You can control the scope of the popular query suggestion with the following setting in the _Project Configuration_ under the _SETTINGS_ tab of a project.

|  |  |  |
| --- | --- | --- |
| **Name** | **Value** | **Description** |
| `topic.typeahead.popular.scope` | `project` `user` Default: `project` | Scope on which popular queries are analysed. - `user`: each user only sees their own popular queries. - `project`: popular queries are aggregated per project and thus the number of users running the same search will make the query more popular overall. |
