v1.0.156

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 or Sphinx Extension can combine all indexes, existing in your configuration, to boost 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 where you can configure them.

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

  • Title - title of the search index.
  • Type - shows 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 current index is ready for search. Disabled value means, that index will be excluded from 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 index to be excluded from search - just change its status to Disable.

Back to top

Adding and Configuring New Index

  1. To add a new index to 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 from their type. Common settings are shown in General Settings subsection:

    • Title - title of the search index. It will be used as tab header at search display page.
    • Type - shows 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. Extension will sort tabs on search results page based on position.
    • Active - sets, whether index should be activated.
  3. Press Save and Continue Edit to proceed to index configuration stage.

  4. Add Searchable Attributes to the type-dependent option list, with rows corresponding to attributes, where extension should conduct 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 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 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 index and activate it to include to search.

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

Back to top

Product Index

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

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

  • Search by Parent Categories Name - include to search all parent categories (useful, when store has wide categories tree).
  • Search by child products - include to 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).
  • Push "out of stock" products to the end - force sorting of search results by stocks inventory, so 'out of stocks' products will be displayed last.
  • Search only by active categories - display only products, which are assigned to at least one active category
  • Force sort order by - overrides default sort order of search results by one of these options:
    • Relevance - sorting by maximum relevance with search request
    • Name - sorting by names in alphanumeric order.
    • Creation Time - sorting by date of adding products to store
    • Price 0-9 - sorting from cheapest to most expensive.
    • Price 9-0 - sorting from expensive to cheapest.

Back to top

Category Index

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

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

Back to top

CMS Index

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

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

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

Back to top

Attribute Index

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

This attribute should be previously enabled for Advanced Search. It can be done at Stores -> Attributes -> Product grid. Pick up desired attribute, then jump to Storefront Properties subsection and then make them 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 similar, you have to make them selectable first, and then make them available for search as above.

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

Back to top

Wordpress Blog Search Index

Wordpress Blog Index can be created at System -> Search Management -> Search Indexes grid. Read more here about 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.

      Example

      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',
              ),
          ),
         ),

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

      Example

      A typical separate database connection should look similar to this:

      'db' => [
      'table_prefix' => '',
      'connection' => [
          'default' => [
              'host' => 'localhost',
              'dbname' => 'dbname',
              'username' => 'username',
              'password' => 'password',
              'active' => '1',
          ],
      
      'wpconnection' => [
      
              'host' => 'localhost',
              'dbname' => 'your_wp_dbname',
              'username' => 'username',
              'password' => 'password',
              'active' => '1',
          ]
      ]
      ],
      'resource' => [
      'default_setup' => [
          'connection' => 'default'
      ],
      'wp_setup' => [
          'connection' => 'wpconnection'
      ]
      ],

  • Table Prefix - the prefix for the wordpress tables (wp_ by default) or login to MySQL: use your_wp_dbname; show tables;
  • Url Template - the full URL for your posts with dynamical variables.

    Typical base urls should look like example below below:

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

Back to top