Enable Statistics Collection

The solrfacetsearch extension supports collecting statistical data for queries sent to the Solr server..

Basic Configuration

Procedure

  1. Enable the statistics collection.
    solrStats.enableCollectingStatistics=true
  2. By default, Solr collects statistical data in files located in the following folder:
    solrStats.filesLocation=${HYBRIS_LOG_DIR}/solrstats
  3. The files holding statistical data are have a prefix as in the example provided below
    solrStats.filePrefix=stats.log
  4. Files are rolled every single hour, this is configured by the following property
    solrStats.dateFormat=yyyy-MM-dd.HH

Collected Data

If you enable the collection of statistical data, then the following information is stored to the Solr server once each query is executed:

  • Date

  • Index configuration

  • Language

  • Query

  • Number of results

Use a Cronjob to Collect Statistics

Context

You should create cron job to store aggregated values into the database. The following information is than stored: date, index, configuration, language, query, average number of results for query, and count.

Procedure

  1. Navigate to Start of the navigation pathSystem Next navigation step Background Processes Next navigation step CronJobsEnd of the navigation path

    A list of defined cronjobs appears on the right.

  2. Click the button.

    A list of available cronjob types appears.

  3. Select the SolrQueryStatisticsCollectorCronJob cronjob.
  4. Use the wizard window provide the required values.
    The most important values for you to provide are:
    • Code: a code (name) for your cronjob that makes it easier to distinguish. It can be for example: Solr Statistics Collection for

    • Job definition: a type of job to be executed. For this particular one, select SolrQueryStatisticsCollectorJob.

    The remaining fields can be filled in at any time in the editor mode.
  5. Click Done to finish.

    Your new cronjob is now visible on the list. To run it, follow the steps described in:Running a CronJob.

Query for Statistics

To get the statistics you can use the following query:

SELECT {PK} FROM {SolrQueryAggregatedStats}

SolrQueryAggregatedStats contains the following attributes:

  • time

  • indexConfig

  • language

  • query

  • count

  • avgNumberOfResults