Configure Search Indexes

Search Indexes are the most important part of your search subsystem. The purpose of storing an index is to optimize speed and performance in finding relevant documents for a search query. Without an index, the search engine would scan every document on your store, which would require considerable time and computing power.

This section covers all topics necessary for working with indexes, and consists of the following subsections:

Managing Indexes

Our Magento 2 Elasticsearch Extension and Sphinx Extension can combine all indexes existing in your configuration, to boost the search and give your customers the most relevant results. It brings them all to a single grid, located at System -> Search Management -> Search Indexes, from which you can configure them.

Each index, added to this grid, displays the following properties:

  • Title - title of the search index.
  • Type - shows the index type (searchable content type - read more at Adding New Index subsection).
  • Position - the position of the index in the search results. Search results will be organized in tabs according to this property.
  • Status - indicates whether the current index is ready for searching. Disabled value means that particular index will be excluded from the search.

Additional Action column provides common actions that can be performed directly from grid, such as:

  • Edit - edit index settings (default action).
  • Reindex - run manual reindexing for selected index.
  • Delete - remove index from Mirasvit Search extension. %

    Note

    This action will completely remove this index from your store, so if you wish for the index to be excluded from search - just change its status to Disable.

Adding and Configuring New Index

  1. To add a new index to the Mirasvit Search extension, go to System -> Search Management -> Search Indexes and press Add New Index.

  2. Index record creation are divided into two stages: setting common settings and specific, which depend on their type. Common settings are shown in the General Settings subsection:

    • Title - title of the search index. It will be used as a tab header at the search display page.
    • Type - shows the index type (searchable content type). Some values of this field will trigger specific options. Pick a link from type list below to know more:
    • Position - the position of the index in the search results. The extension will sort tabs on search results page based on the position.
    • Active - sets, whether index should be activated.
  3. Press Save and Continue Edit to proceed to the index configuration stage.

  4. Add Searchable Attributes to the type-dependent option list, with rows corresponding to attributes where the extension should conduct a search. Each row consist of the following fields:
    • Attribute - attribute name. It is picked from properties of selected index type. For example, if Product type is selected - then attributes would be Product Name, SKU, Price, Tax Class and so on.
    • Weight - sort order, which defines the importance of each attribute for product relevancy. The maximum weight is 10 (highest priority), the minimum weight is 0(lowest priority). Each index type comes with a predefined set of searchable options that will be displayed after completing the first stage. There should be at least one searchable attribute, otherwise the search will not work properly.
  5. Properties - type-dependent specific options section. Read more below, or pick a link from type values, described in (2) step.

  6. Save the index and activate it to be included in the search.

During installation, three indexes will be automatically created and configured: Product, Category and CMS Page.

Product Index

Product Index can be created at System -> Search Management -> Search Indexes grid. Read more about it here: adding new index.

Specific options of this type will be shown on the Properies section of the Index edit page:

  • Search by Parent Categories Name - include in the search all parent categories (useful, when a store has a wide categories tree).
  • Search by child products - include in the search associated products from Bundled, Grouped and Configurable products.
  • Search by Product ID - enable search by product id (entity_id attribute, which is not listed as searchable by Magento).
  • Search by custom options - enable search by custom options (defined additionally to existing ones).

Category Index

Category Index can be created at System -> Search Management -> Search Indexes grid. Read more about it here: adding new index.

There's no specific options for this type of index.

CMS Index

CMS Page Index can be created at the System -> Search Management -> Search Indexes grid. Read more about it here: adding new index.

There's only one specific option for this type on Properies section of Index edit page:

  • Ignored CMS Pages - defines, on whose CMS pages search should not be performed. You can select zero or more pages here via the checkbox drop-down list.

Attribute Index

Unlike other indexes, this one can be created only for a specific attribute which should be displayed as a separate section in the Search Results.

This attribute should be previously enabled for Advanced Search. It can be done at Stores -> Attributes -> Product grid. Pick up the desired attribute, then jump to the Storefront Properties subsection and make it available for search by setting to Yes two options: Use in Search and Visible in Advanced Search.

Note

Attribute index can work only with attributes, that can be indexed, e. q. they belong to selectable type.

To see type of Product Attribute, visit Stores -> Attributes -> Product grid, pick up attribute record, and see Catalog Input Type for Store Owner field. Selectable types are Multiple Select and Dropdown. Only attributes of this type can be indexed.

If you wish to use attributes like Author, or something similar, you have to make them selectable first, and then make them available for searching as above.

After saving the product, you can configure Attribute Index for this attribute at System -> Search Management -> Search Indexes grid. Read more about it here: adding new index.

Wordpress Blog Search Index

Wordpress Blog Index can be created at the System -> Search Management -> Search Indexes grid. Read more about it here: adding new index.

  • Database Connection Name - connection name of the Wordpress database.

    • If WordPress is installed on the same database, the correct value is default.
    • If WordPress is installed on a separate database, you need to create a new connection in file app/etc/env.php.

      Example

      A typical database connection should look similar to this:

          'db' => array(
          'table_prefix' => '',
          'connection' => array(
              'default' => array(
                  'host' => 'localhost',
                  'dbname' => 'store',
                  'username' => 'root',
                  'password' => 'password',
                  'active' => '1',
              ),
          ),
         ),

  • Table Prefix - the prefix for the Wordpress tables (wp_ by default).
  • Url Template - the full URL for your posts with dynamical variables.

    Typical base urls should look like the example below:

    http://example.com/blog/{post_name}.html
    http://example.com/blog/?p={ID}
    http://example.com/{category_slug}/{post_name}.html