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 via phpMorphy (Russian, English, German, Ukrainian)
  • Dictionary index — fast search with configurable field weights
  • Search aliases — synonyms and replacements to 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

Requirements

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

Dependencies

  • pdoTools 3.x — for snippets and Fenom
  • VueTools — for 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 Indexing tab and create a search index

Quick start

1. Create search page

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

2. Add form and results

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

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

3. Configure indexing

Set indexed fields in system settings:

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

Numbers are field weights. Higher weight ranks matches in that field higher.

System settings

All settings use prefix mse_ and namespace msearch.

Indexing

SettingDefaultDescription
mse_index_fieldspagetitle:3,longtitle:2,description:2,introtext:2,content:1Indexed fields with weights
mse_index_min_word_length3Minimum word length to index
mse_index_split_words#\s|[,.:;!?"'«»„"()\[\]{}<>]#uRegex to split text into words
mse_use_schedulerfalseUse Scheduler for deferred indexing
SettingDefaultDescription
mse_search_exact_match_bonus10Bonus for exact query match
mse_search_like_match_bonus3Bonus for LIKE match
mse_search_all_words_bonus5Bonus when all query words are found
mse_search_split_words#\s+#uRegex to split query

Frontend

SettingDefaultDescription
mse_frontend_css[[++assets_url]]components/msearch/css/web/msearch.cssCSS URL
mse_frontend_js[[++assets_url]]components/msearch/js/web/msearch.jsJS URL

Placeholders

After search:

PlaceholderDescription
[[+mse.total]]Total results
[[+mse.query]]Processed query

In result chunk (tpl):

PlaceholderDescription
[[+weight]]Result weight (relevance)
[[+intro]]Text with highlighted matches
[[+idx]]Result index

Events

EventDescription
mseOnRegisterAdaptersRegister adapters for custom model indexing
mseOnBeforeIndexBefore indexing a resource
mseOnGetWorkFieldsChange list of fields to index
mseOnAfterIndexAfter indexing a resource
mseOnBeforeSearchBefore running search
mseOnAfterSearchAfter 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)
FilteringmFilter2No (use pdoTools)
phpMorphyBundledComposer cijic/phpmorphy
Dictionary sourceSourceForgeGitHub
EstonianYesNo
SchedulerNoYes (deferred indexing)

mFilter2

The mFilter2 snippet is not part of mSearch. Use pdoTools or other 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

fenom
{'!mSearchForm' | snippet: ['pageId' => $_modx->resource.id]}

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

{$_modx->getPlaceholder('page.nav')}
fenom
{'!pdoPage' | snippet: [
    'element' => 'msProducts',
    'parents' => 0,
    'resources' => '!mSearch' | snippet: ['return' => 'ids', 'limit' => 0] | default : '999999',
    'sortby' => 'ids'
]}

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

Support