Skip to content
  1. Extras
  2. mSearch

mSearch ​

Full-text search with morphological analysis for MODX Revolution 3.x.

Features ​

  • Morphological analysis — search by word forms with the phpMorphy library (Russian, English, German, Ukrainian)
  • Dictionary index — fast search with configurable field weights
  • Search aliases — synonyms and replacements that broaden results
  • Query statistics — track popular queries
  • Automatic indexing — on resource save
  • Deferred indexing — background indexing via Scheduler
  • Vue interface — admin panel on Vue 3 + PrimeVue
  • Autocomplete — suggestions while typing
  • Public API — REST endpoint for AJAX search and integrations
  • Headless mode — JavaScript API (window.msearch) for React, Vue and custom UIs
  • Hook system — extend search behavior with msearchHooks
  • Multi-context — filter results by MODX contexts

Requirements ​

RequirementVersion
MODX Revolution3.0.0+
PHP8.1+
MySQL5.7+ / MariaDB 10.3+

Dependencies ​

  • pdoTools 3.x — for snippets and the Fenom template engine
  • VueTools 1.2.0+ — for the admin interface
  • Scheduler (optional) — for deferred indexing

Installation ​

Via package manager ​

  1. Go to Extras → Installer
  2. Click Download Extras
  3. Find mSearch in the list
  4. Click Download, then Install

After installation:

  1. Go to Extras → mSearch → Dictionaries
  2. Download a morphological dictionary for your language (Russian, English, German, Ukrainian)
  3. Open the Index tab and create the search index

Dictionaries tab: the Russian dictionary is installed, the others have install buttons

Quick start ​

1. Create a search page ​

Create a resource for search results, e.g. /search/.

2. Add the form and results ​

fenom
{'!mSearchForm' | snippet : [
    'pageId' => 5,
    'autocomplete' => 1
]}

{'!mSearch' | snippet : [
    'tpl' => 'mSearch.row',
    'limit' => 10
]}

3. Configure indexing ​

Set the indexed fields in system settings:

mse_index_fields = pagetitle:3,longtitle:2,description:2,introtext:2,content:1

The numbers are field weights. The higher the weight, the higher results with matches in that field rank.

mSearch settings are grouped into the Indexing, Search and Frontend areas — filter system settings by the msearch namespace:

mSearch system settings grouped by area; mse_index_fields with its default value

System settings ​

Settings live in the msearch namespace with the mse_ prefix and are grouped into the Indexing, Search and Frontend areas.

Full reference with defaults and use cases: System settings.

Placeholders ​

After a search the following placeholders are available:

PlaceholderDescription
[[+mse.total]]Total number of results found
[[+mse.query]]Search query as entered (before alias processing)

In the result chunk (tpl):

PlaceholderDescription
[[+weight]]Result weight (relevance)
[[+intro]]Text with highlighted matches
[[+idx]]Result number in the list

Events ​

EventDescription
mseOnRegisterAdaptersRegister adapters for indexing your own models
mseOnBeforeIndexBefore indexing a resource
mseOnGetWorkFieldsChange the list of fields to index
mseOnAfterIndexAfter indexing a resource
mseOnBeforeSearchBefore running a search
mseOnAfterSearchAfter running a search

Differences from mSearch2 ​

mSearch is a full rewrite for MODX 3.x:

AspectmSearch2mSearch
MODX2.x3.x
PHP5.6+8.1+
InterfaceExtJSVue 3 + PrimeVue
ArchitectureProceduralService-based
AliasesSynonymsAliases (synonyms + replacements)
FilteringmFilter2None (use pdoTools)
phpMorphyBundledComposer package cijic/phpmorphy
Dictionary sourceSourceForgeGitHub
EstonianYesNo
SchedulerNoYes (deferred indexing)

mFilter2

The mFilter2 snippet is not part of mSearch. Use the standard pdoTools features or third-party solutions for filtering.

Examples ​

fenom
<form action="{'search' | url}" method="get">
    <input type="text" name="mse_query" value="{$_GET['mse_query']}" placeholder="Search...">
    <button type="submit">Search</button>
</form>

{'!mSearch' | snippet : [
    'tpl' => 'mSearch.row',
    'limit' => 10
]}

With pagination ​

mSearch reads offset and writes the total number of results to totalVar, so pdoPage can page through it directly:

fenom
{'!pdoPage' | snippet : [
    'element' => 'mSearch',
    'totalVar' => 'page.total',
    'tpl' => 'mSearch.row',
    'limit' => 10
]}

{$_modx->getPlaceholder('page.nav')}

For miniShop3 products (they are rendered by msProducts, not mSearch) use the return=ids pattern — see below.

fenom
{'!pdoPage' | snippet : [
    'element' => 'msProducts',
    'parents' => 0,
    'resources' => '!mSearch' | snippet : ['return' => 'ids', 'limit' => 0] | default : '999999',
    'sortby' => 'ids'
]}

{$_modx->getPlaceholder('page.nav')}

Support ​