# Backend search index for media

## Overview

Enabling the *Backend search* index allows for more comprehensive search results in the backend. When the index is not activated (default behavior), your search only looks in the titles of media content items. If you activate the index, in addition to the search results from titles, you also get search results from library name, tag, category, and file URL.

> info **NOTE**: The backend search index only works for media content items and by default, it is inactive. The scope of the backend search index is read-only (cannot be modified).\
> To implement search for other fields, use the sample [Extending search functionality in AdminApp](https://github.com/Sitefinity/sitefinity-admin-app-extensions/tree/e4a642963792f04d5c7ab1dbac876f89e7fb72dc/src/search) on Sitefinity GitHub repository.

## Activate backend search index

The backend search functionality is enabled by default, but the backend search index must be activated so you can get search results other than media item titles. To do this, perform the following:

1. Navigate to *Administration » Search indexes*.\
   There is an index named *Backend search* that, by default, is inactive.
2. Expand the *Actions* menu of the *Backend search* and click *Reindex*.\
   The operation may be time consuming. While the operation is running, you see the reindexing status progress.

> success **RESULT:** Once the reindexing is completed, the *Backend search* index becomes active and you can start using media search with more comprehensive results.

To configure the backend search functionality, perform the following:

1. Navigate to *Administration » Settings » Advanced » Search*.
2. To enable or disable the backend search, select/deselect *Enable backend search*.
3. Click *Save changes*.

## Use one search service across multiple environments without sharing the search indexes

> info  **PREREQUISITES**:
>
> * The following configuration applies only when you use Azure Search and Elasticsearch.
> * To use separate search indexes, you need to use Sitefinity CMS 15.4.8628 or later.

Depending on your business needs, you may decide to use different search indexes for your different environments. For example, you may want developers working on a development environment, content editors working on the UAT environment, and the site visitors using your production environment to be able to use search that indexes only the content available on the respective environment. At the same time, you may have cost, legal, security, or other limitations which requires you to use the same cloud search service.

To achieve this separation of search indexes, you can configure per-environment prefix for the name of the search index. In this way, Sitefinity CMS automatically ensures that each environment uses an uniquely named search index which is separate from other search indexes in the same search provider. This search index is unique, thus it counts towards your quota for your search index provider (such as Azure Search or Elasticsearch).

To configure the per-environment search index name prefix manually, perform the following:

1. Log in to Sitefinity CMS backend using an administrator account.
2. Navigate to *Administration » Settings » Advanced » Search*.
3. In the *Environment index prefix*, enter the prefix.\
   For example, enter `dev-`.
4. Save the changes.

Sitefinity CMS merges the prefix with the encoded name of the search index.\
For example, if you enter `dev-` as environment index prefix, and your search index name is `backend`, the name of the search index in your cloud search provider would be `dev-backend`.

You can automate the process using configuration settings transformations. For more information, see [Manage configurations in Continuous delivery pipeline](https://www.progress.com/documentation/sitefinity-cms/manage-configurations-in-cd-pipeline).

## Reduce the size of the backend search index

If you have a big database with lots of master items, the backend search index size may increase significantly, which may be costly in cloud deployments. In such scenario, you can configure Sitefinity CMS to not store different versions for Live and Master items and reduce the size of the backend search index.\
To turn on this setting, perform the following:

1. In Visual Studio, open your Sitefinity CMS project.

2. Expand *App_Data » Sitefinity » Configuration* and open `SearchConfig.config`.

3. Search for the `searchConfig` tag and add this attribute: `disableIndexingLifecycleVersions="true"`\
   After the modification your config file should look like this:

   ```XML
   <?xml version="1.0" encoding="utf-8"?>
   <searchConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="13.2.7500.0" disableIndexingLifecycleVersions="true" 
   />
   ```

4. Build and deploy your Sitefinity CMS solution.

## Find media items

The backend search works for images, videos, and documents. To use it, navigate to the *Images*, *Videos*, or *Documents & Files* page.

The search performs a `startswith` on each term with an `AND` between terms. The search looks at titles, tags, categories, file URLs, and library names. URL searches return whole word results from the relative URL of the item.

> success **EXAMPLE**: If you have an image with the following URL *[www.mysite.com/image-album/my-image.png](http://www.mysite.com/image-album/my-image.png)*, the search looks only in the */image-album/my-image.png* part of the URL and returns results for *image*, *album*, *my*, *image*, *my-image.png* and */image-album/my-image.png* inputs. You can also search with .`png` input and the search returns all images with the `.png` extension but also terms that start with *png*.

This search behavior is consistent with the default frontend search behavior. For more information, see [Site search](https://www.progress.com/documentation/sitefinity-cms/internal-search-search-indexes).

## Improve media items location

The *Backend search* index also improves the process of locating media items - such as images, documents, and videos - on pages and links to media items. Once the index is activated and reindexed, you can see where media items are used or linked to from the *Actions* menu of the media item. The results are displayed in the *Pages displaying this…* media type for images, documents, and videos. For more information, see [Image actions](https://www.progress.com/documentation/sitefinity-cms/image-actions), [Document actions](https://www.progress.com/documentation/sitefinity-cms/edit-the-properties-of-documents-and-files), and [Video actions](https://www.progress.com/documentation/sitefinity-cms/video-actions).\
After activating the index, media items are tracked in the following locations:

* Content blocks\
  Media and content links in content blocks are tracked after activating the index.
* Long-text fields\
  Media and content links in long-text fields are tracked after activating the index.
* Page templates\
  Pages with page templates with media widgets and content blocks with relations to media items are tracked after activating the index.
* Forms\
  Forms with content blocks that have media items relations are tracked after activating the index.
* Content items\
  Long-text fields in content items, such as news, lists, list items, blogs, blog posts, events, media items, custom content and pages are tracked after activating the index. If the index is not activated, only media items in the related media fields are tracked. For more information, see [Add related data and related media](https://www.progress.com/documentation/sitefinity-cms/add-related-data-and-related-media).\
  These relations are displayed in the *Items displaying this…* media type pages available from the *Actions* menu of the media type. For more information, see [Image actions](https://www.progress.com/documentation/sitefinity-cms/image-actions), [Document actions](https://www.progress.com/documentation/sitefinity-cms/edit-the-properties-of-documents-and-files), and [Video actions](https://www.progress.com/documentation/sitefinity-cms/video-actions).

This is in addition to media widgets, such as the *Image* and *Video* widgets and gallery widgets, and related media custom fields that are already tracked even if the index is not active.

> success **EXAMPLE:** You have several pages that display the same image in different ways. One of the pages displays it with the *Image* widget. Another one has it inserted in a content block. Other pages include it as a link or in long-text fields.  To see all the pages where this image is used you have to perform the following:
>
> 1. Navigate to *Content » Images*.
> 2. Browse the libraries to find the image or use the search box.
> 3. Select the image and expand the *Actions* menu.
> 4. Click *Pages displaying this image*.\
>    The *Pages displaying image* page appears. Here you can see a list with links to all the pages displaying this image.\
>    If you want to see all the items linking or displaying this image, click *Items displaying this image* instead.\
>    The *Items displaying image* appears with a list with links to all the content items displaying this image.
