Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Mroonga (formerly named Groonga Storage Engine) is a storage engine that provides fast CJK-ready full text searching using column store.
Extend Mroonga's functionality in MariaDB Server with user-defined functions. Learn how to create custom functions to enhance full-text search and data processing capabilities.
Learn about the Mroonga storage engine, which provides fast CJK-ready full-text searching using column-based storage and supports Groonga's features.
Once Mroonga has been installed (see About Mroonga), its basic usage is similar to that of a regular fulltext index.
For example:
Mroonga can also order by weighting. For example, first add another record:
Records can be returned by weighting, for example, the newly added record has two occurences of the word 'wicked' and a higher weighting:
Mroonga permits you to set a different parser for searching by specifying the parser in the CREATE TABLE statement as a comment or, in older versions, changing the value of the system variable.
For example:
or
The following parser settings are available:
TokenBigram failing to match partial symbols which TokenBigramSplitSymbol matches, since TokenBigramSplitSymbol does not treat continuous symbols as a token.
This page is licensed: CC BY-SA / Gnu FDL
This UDF normalizes a given string using Groonga's normalizers, ensuring consistent text processing for accurate indexing and searching.
mroonga_normalize(string[, normalizer_name])mroonga_normalize is a (UDF) included with the . It uses Groonga's normalizer to normalize text. See for details on creating this UDF if required.
Given a string, returns the normalized text.
See the for details on the Groonga normalizers. The default if no normalizer is provided is NormalizerAuto.
This page is licensed: CC BY-SA / Gnu FDL
Highlight keywords within a text string using HTML tags, making it easy to display search results with matched terms emphasized.
mroonga_highlight_html(text[[, query AS query]])
mroonga_highlight_html(text[[, keyword1, ..., keywordN]])mroonga_highlight_html is a (UDF) included with the . It highlights the specified keywords in the target text. See for details on creating this UDF if required.
The optional parameter can either be one or more keywords, or a Groonga query.
The function highlights the specified keywords in the target text by surrounding each keyword with <span class="keyword">...</span>, and escaping special HTML characters such as < and >.
Returns highlighted HTML.
Highlighting the words MariaDB and Mroonga in a given text:
The same outcome, formulated as a Groonga query:
This page is licensed: CC BY-SA / Gnu FDL
Execute raw Groonga commands directly from MariaDB using this UDF, allowing for advanced administration and inspection of the Groonga database.
mroonga_command (command)mroonga_command is a (UDF) included with the . It passes a command to Groonga for execution. See for details on creating this UDF if required.
command - string, required parameter specifying the command to pass that are executed by Groonga. See for a list of commands.
Returns the result of the Groonga command.
This page is licensed: CC BY-SA / Gnu FDL
This function escapes special characters in a string to make it safe for use in Mroonga full-text search queries.
mroonga_escape (string [,special_characters])string - required parameter specifying the text you want to escape
special_characters - optional parameter specifying the characters to escape
mroonga_escape is a (UDF) included with the , used for escaping a string. See for details on creating this UDF if required.
If no special_characters parameter is provided, by default +-<>*()": are escaped.
Returns the escaped string.
This page is licensed: CC BY-SA / Gnu FDL
A list of status variables specific to Mroonga, used to monitor internal operations like fast line counts and order-by-limit optimizations.
This page documents status variables related to the Mroonga storage engine. See Server Status Variables for a complete list of status variables that can be viewed with SHOW STATUS.
Mroonga_count_skipDescription: Incremented each time the 'fast line count feature' is used. Can be used to check if the feature is working after enabling it.
Data Type: numeric
Mroonga_fast_order_limitDescription: Incremented each time the 'fast ORDER BY LIMIT feature' is used. Can be used to check if the feature is working after enabling it.
Data Type: numeric
This page is licensed: CC BY-SA / Gnu FDL
This UDF returns the unique ID assigned by Groonga for the last inserted record, useful for tracking internal record identifiers.
This page provides version history, installation instructions, and limitations for the Mroonga storage engine, highlighting its full-text search capabilities.
Mroonga is a full-text search storage engine based on Groonga, which is an open-source CJK-ready (Chinese, Japanese, and Korean) fulltext search engine using column base. See for more.
With Mroonga, you can have a CJK-ready full text search feature, and it is faster than the and for both updating and searching.
Mroonga also supports Groonga's fast geolocation search by using MariaDB's geolocation SQL syntax.
Mroonga only supports Linux x86_64 (Intel64/AMD64).
Instructions on how to manually create Mroonga's UDFs if they were not automatically installed, ensuring full functionality.
The includes a number of that need to be created before they can be used. If these are not created already during Mroonga setup, you will need to do so yourself. The full list of available functions and the statements to create them are found in share/mroonga/install.sql, for example, as of Mroonga 7.07 running on Linux:
This page is licensed: CC BY-SA / Gnu FDL
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy)) ENGINE=Mroonga;
INSERT INTO ft_mroonga(copy) VALUES ('Once upon a time'),
('There was a wicked witch'), ('Who ate everybody up');
SELECT * FROM ft_mroonga WHERE MATCH(copy) AGAINST('wicked');
+--------------------------+
| copy |
+--------------------------+
| There was a wicked witch |
+--------------------------+INSERT INTO ft_mroonga(copy) VALUES ('She met a wicked, wicked witch');SELECT *, MATCH(copy) AGAINST('wicked') AS score FROM ft_mroonga
WHERE MATCH(copy) AGAINST('wicked') ORDER BY score DESC;
+--------------------------------+--------+
| copy | score |
+--------------------------------+--------+
| She met a wicked, wicked witch | 299594 |
| There was a wicked witch | 149797 |
+--------------------------------+--------+TokenBigramSplitSymbol
Same as TokenBigram except that continuous symbols are not treated as a token, but tokenised in bigram.
TokenBigramSplitSymbolAlpha
Same as TokenBigram except that continuous alphabetical characters are not treated as a token, but tokenised in bigram.
TokenDelimit
Tokenises by splitting on white spaces.
TokenDelimitNull
Tokenises by splitting on null characters (\0).
TokenMecab
Tokenise using MeCab. Required Groonga to be buillt with MeCab support.
TokenTrigram
Tokenises in trigrams but continuous alphabetical characters, numbers or symbols are treated as a token.
TokenUnigram
Tokenises in unigrams but continuous alphabetical characters, numbers or symbols are treated as a token.
off
No tokenizing is performed.
TokenBigram
Default value. Continuous alphabetical characters, numbers or symbols are treated as a token.
TokenBigramIgnoreBlank
Same as TokenBigram except that white spaces are ignored.
TokenBigramIgnoreBlankSplitSymbol
Same as TokenBigramSplitSymbol. except that white spaces are ignore.
TokenBigramIgnoreBlankSplitSymbolAlpha
Same as TokenBigramSplitSymbolAlpha except that white spaces are ignored.
TokenBigramIgnoreBlankSplitSymbolAlphaDigit
Same as TokenBigramSplitSymbolAlphaDigit except that white spaces are ignored.
On Debian and Ubuntu mroonga engine are installed with
See Plugin overview for details on installing and uninstalling plugins.
SHOW ENGINES can be used to check whether Mroonga is installed correctly:
Once the plugin is installed, add a UDF (User-Defined Function) named "last_insert_grn_id", that returns the record ID assigned by groonga in INSERT, by the following SQL.
The maximum size of a single key is 4096 bytes.
The maximum size of all keys is 4GB.
The maximum number of records in a fulltext index is 268,435,455
The maximum number of distinct terms in a fulltext index is 268,435,455
The maximum size of a fulltext index is 256GB
Note that the maximum sizes are not hard limits, and may vary according to circumstance.
For more details, see limitations.html.
Mroonga supports a limited number of character sets. These include:
ASCII
BINARY
CP932
EUCJPMS
KOI8R
LATIN1
SJIS
UJIS
UTF8
UTF8MB4
Further documentation for Mroonga can be found at
This page is licensed: CC BY-SA / Gnu FDL
SELECT last_insert_grn_id();
+----------------------+
| last_insert_grn_id() |
+----------------------+
| 3 |
+----------------------+DROP FUNCTION IF EXISTS last_insert_grn_id;
CREATE FUNCTION last_insert_grn_id RETURNS INTEGER
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_snippet;
CREATE FUNCTION mroonga_snippet RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_command;
CREATE FUNCTION mroonga_command RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_escape;
CREATE FUNCTION mroonga_escape RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_snippet_html;
CREATE FUNCTION mroonga_snippet_html RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_normalize;
CREATE FUNCTION mroonga_normalize RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_highlight_html;
CREATE FUNCTION mroonga_highlight_html RETURNS STRING
SONAME 'ha_mroonga.so';
DROP FUNCTION IF EXISTS mroonga_query_expand;
CREATE FUNCTION mroonga_query_expand RETURNS STRING
SONAME 'ha_mroonga.so';This function extracts a snippet of text surrounding a keyword from a document, providing necessary context for search result displays.
mroonga_snippet is a (UDF) included with the . It provides a keyword with surrounding text, or the keyword in context. See for details on creating this UDF if required.
The required parameters include:
document - Column name or string value.
max_length - Maximum length of the snippet, in bytes.
max_count - Maximum snippet elements (N word).
The optional parameters include:
wordN - A word.
wordN_prefix - wordN start text.
wordN_suffix - wordN end text
It can be used in both storage and wrapper mode.
Returns the snippet string.
This page is licensed: CC BY-SA / Gnu FDL
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy) COMMENT 'parser "TokenDelimitNull"')
ENGINE=Mroonga;,SET GLOBAL mroonga_default_parser = 'TokenBigramSplitSymbol';DROP TABLE ft_mroonga;
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy) COMMENT 'parser "TokenBigram"')
ENGINE=Mroonga;
INSERT INTO ft_mroonga(copy) VALUES ('Once upon a time'),
('There was a wicked witch'),
('Who ate everybody up'),
('She met a wicked, wicked witch'),
('A really wicked, wicked witch!!?!');
SELECT * FROM ft_mroonga WHERE MATCH(copy) AGAINST('!?');
Empty set (0.00 sec)
DROP TABLE ft_mroonga;
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy) COMMENT 'parser "TokenBigramSplitSymbol"')
ENGINE=Mroonga;
INSERT INTO ft_mroonga(copy) VALUES ('Once upon a time'),
('There was a wicked witch'),
('Who ate everybody up'),
('She met a wicked, wicked witch'),
('A really wicked, wicked witch!!?!');
SELECT * FROM ft_mroonga WHERE MATCH(copy) AGAINST('!?');
+-----------------------------------+
| copy |
+-----------------------------------+
| A really wicked, wicked witch!!?! |
+-----------------------------------+DROP TABLE ft_mroonga;
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy) COMMENT 'parser "TokenBigram"')
ENGINE=Mroonga;
INSERT INTO ft_mroonga(copy) VALUES ('Once upon a time'),
('There was a wicked witch'),
('Who ate everybody up'),
('She met a wicked, wicked witch'),
('A really wicked, wicked witch!!?!');
SELECT * FROM ft_mroonga WHERE MATCH(copy) AGAINST('ick');
Empty set (0.00 sec)
DROP TABLE ft_mroonga;
CREATE TABLE ft_mroonga(copy TEXT,FULLTEXT(copy) COMMENT 'parser "TokenBigramSplitSymbolAlpha"')
ENGINE=Mroonga;
INSERT INTO ft_mroonga(copy) VALUES ('Once upon a time'),
('There was a wicked witch'),
('Who ate everybody up'),
('She met a wicked, wicked witch'),
('A really wicked, wicked witch!!?!');
SELECT * FROM ft_mroonga WHERE MATCH(copy) AGAINST('ick');
+-----------------------------------+
| copy |
+-----------------------------------+
| There was a wicked witch |
| She met a wicked, wicked witch |
| A really wicked, wicked witch!!?! |
+-----------------------------------+INSTALL SONAME 'ha_mroonga';sudo apt-get install mariadb-plugin-mroongaSHOW ENGINES;
...
*************************** 8. row ***************************
Engine: Mroonga
Support: YES
Comment: CJK-ready fulltext search, column store
Transactions: NO
XA: NO
Savepoints: NO
...CREATE FUNCTION last_insert_grn_id RETURNS INTEGER SONAME 'ha_mroonga.so';SELECT mroonga_normalize("ABぃ㍑");
+-------------------------------+
| mroonga_normalize("ABぃ㍑") |
+-------------------------------+
| abぃリットル |
+-------------------------------+SELECT mroonga_highlight_html('<p>MariaDB includes the Mroonga storage engine</p>.')
AS highlighted_html;
+-----------------------------------------------------------------+
| highlighted_html |
+-----------------------------------------------------------------+
| <p>MariaDB includes the Mroonga storage engine</p>. |
+-----------------------------------------------------------------+SELECT mroonga_highlight_html('MariaDB includes the Mroonga storage engine.', 'MariaDB', 'Mroonga')
AS highlighted_html;
+--------------------------------------------------------------------------------------------------------+
| highlighted_html |
+--------------------------------------------------------------------------------------------------------+
| <span class="keyword">MariaDB</span> includes the <span class="keyword">Mroonga</span> storage engine. |
+--------------------------------------------------------------------------------------------------------+SELECT mroonga_highlight_html('MariaDB includes the Mroonga storage engine.', 'MariaDB OR Mroonga'
AS query) AS highlighted_text;
+--------------------------------------------------------------------------------------------------------+
| highlighted_text |
+--------------------------------------------------------------------------------------------------------+
| <span class="keyword">MariaDB</span> includes the <span class="keyword">Mroonga</span> storage engine. |
+--------------------------------------------------------------------------------------------------------+SELECT mroonga_command('status');
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| mroonga_command('status') |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {"alloc_count":593,"starttime":1512022368,"start_time":1512022368,"uptime":13510,"version":"7.0.7","n_queries":0,"cache_hit_rate":0.0,"command_version":1,"default_command_version":1,"max_command_version":3} |SELECT mroonga_escape("+-<>~*()\"\:");
'\\+\\-\\<\\>\\~\\*\\(\\)\\"\\:mroonga_snippet document,
max_length,
max_count,
encoding,
skip_leading_spaces,
html_escape,
snippet_prefix,
snippet_suffix,
word1, word1_prefix, word1_suffix
...
[wordN wordN_prefix wordN_suffix]encoding - Encoding of the document, for example cp932_japanese_ciskip_leading_spaces - 1 to skip leading spaces, 0 to not skip.
html_escape = 1 to enable HTML espape, 0 to disable.
prefix - Snippet start text.
suffix - Snippet end text.
This page documents system variables related to the Mroonga storage engine. See Server System Variables for instructions on setting them.
See also the Full list of MariaDB options, system and status variables.
mroonga_action_on_fulltext_query_errorDescription: Action to take when encountering a Mroonga fulltext error.
ERROR: Report an error without logging.
ERROR_AND_LOG: Report an error with logging (the default)
IGNORE: No logging or reporting - the error is ignored.
Command line: --mroonga-action-on-fulltext-query-error=value
Scope: Global, Session
Dynamic: Yes
Data Type: enum
Default Value: ERROR_AND_LOG
mroonga_boolean_mode_syntax_flagsDescription: Flags to customize syntax in BOOLEAN MODE searches. Available flags:
DEFAULT: (=SYNTAX_QUERY,ALLOW_LEADING_NOT)
ALLOW_COLUMN: Allows COLUMN:... syntax in query syntax, an incompatible change to the regular BOOLEAN MODE syntax. Permits multiple indexes in one MATCH () AGAINST ()
mroonga_database_path_prefixDescription: The database path prefix.
Command line: --mroonga-database-path-prefix=value
Scope: Global
Dynamic: Yes
mroonga_default_parserDescription: The fulltext default parser, for example TokenBigramSplitSymbolAlphaDigit or TokenBigram (the default). See the list of options at . Deprecated since Mroonga 5.04, use instead.
Command line: --mroonga-default-parser=value
Scope: Global
mroonga_default_tokenizerDescription: The fulltext default parser, for example TokenBigramSplitSymbolAlphaDigit or TokenBigram (the default). See the list of options at .
Command line: --mroonga-default-tokenizer=value
Scope: Global, Session
mroonga_default_wrapper_engineDescription: The default engine for wrapper mode.
Command line: --mroonga-default-wrapper-engine=value
Scope: Global
Dynamic: No
mroonga_dry_writeDescription: If set to on, (off is default), data is not actually written to the Groonga database. Only really useful to change for benchmarking.
Command line: --mroonga-dry-write[={0|1}]
Scope: Global, Session
mroonga_enable_operations_recordingDescription: Whether recording operations for recovery to the Groonga database is enabled (default) or not. Requires reopening the database with after changing the variable.
Command line: --mroonga-enable-operations-recording={0|1}
Scope: Global
Dynamic: Yes
mroonga_enable_optimizationDescription: If set to on (the default), optimization is enabled. Only really useful to change for benchmarking.
Command line: --mroonga-enable-optimization={0|1}
Scope: Global, Session
Dynamic: Yes
mroonga_libgroonga_embeddedDescription: Whether libgroonga is embedded or not.
Command line: None
Scope: Global
Dynamic: No
mroonga_libgroonga_support_lz4Description: Whether libgroonga supports lz4 or not.
Command line: None
Scope: Global
Dynamic: No
mroonga_libgroonga_support_zlibDescription: Whether libgroonga supports zlib or not.
Command line: None
Scope: Global
Dynamic: No
mroonga_libgroonga_support_zstdDescription: Whether libgroonga supports Zstandard or not.
Command line: None
Scope: Global
Dynamic: No
mroonga_libgroonga_versionDescription: Groonga library version.
Command line: None
Scope: Global
Dynamic: No
mroonga_lock_timeoutDescription: Lock timeout used in Groonga.
Command line: --mroonga-lock-timeout=#
Scope: Global
Dynamic: Yes
mroonga_log_fileDescription: Name and path of the Mroonga log file.
Command line: --mroonga-log-file=value
Scope: Global
Dynamic: Yes
mroonga_log_levelDescription: Mroonga log file output level, which determines what is logged. Valid levels include:
NONE No output.
EMERG: Only emergency error messages, such as database corruption.
mroonga_match_escalation_thresholdDescription: The threshold to determine whether the match method is escalated. -1 means never escalate.
Command line: --mroonga-match-escalation-threshold=#
Scope: Global, Session
Dynamic: Yes
mroonga_max_n_records_for_estimateDescription: The max number of records to estimate the number of matched records
Command line: --mroonga-max-n-records-for-estimate=#
Scope: Global, Session
Dynamic: Yes
mroonga_query_log_fileDescription: Query log file for Mroonga.
Command line: --mroonga-query-log-file=filename
Scope: Global
Dynamic: Yes
mroonga_vector_column_delimiterDescription: Delimiter to use when outputting a vector column. The default is a white space.
Command line: --mroonga-vector-column-delimiter=value
Scope: Global
Dynamic: Yes
mroonga_versionDescription: Mroonga version
Command line: None
Scope: Global
Dynamic: No
This page is licensed: CC BY-SA / Gnu FDL
IGNORE_AND_LOGALLOW_LEADING_NOT Permits using the NOT_INCLUDED_KEYWORD syntax in the query syntax.
ALLOW_UPDATE: Permits updating values with the COLUMN:=NEW_VALUE syntax in the query syntax.
SYNTAX_QUERY: Mroonga will use Groonga's query syntax, compatible with MariaDB's BOOLEAN MODE syntax. Unless SYNTAX_SCRIPT is specified, this mode is always in use.
SYNTAX_SCRIPT: Mroonga will use Groonga's script syntax, a JavaScript-like syntax. If both SYNTAX_QUERY and SYNTAX_SCRIPT are specified, SYNTAX_SCRIPT will take precedence..
Command line: --mroonga-boolean-mode-syntax-flags=value
Scope: Global, Session
Dynamic: Yes
Data Type: enum
Default Value: DEFAULT
Data Type: string
Default Value: (Empty)
Dynamic: Yes
Data Type: string
Default Value: TokenBigram
Deprecated: , Mroonga 5.0.4
Dynamic: Yes
Data Type: string
Default Value: TokenBigram
Introduced: , Mroonga 5.0.4
Data Type: string
Default Value: (Empty)
Data Type: boolean
Default Value: off
Data Type: boolean
Default Value: ON
Introduced: ,
Data Type: boolean
Default Value: on
booleanDefault Value: ON
Introduced:
booleanDefault Value: OFF
booleanDefault Value: ON
booleanDefault Value: OFF
Introduced: ,
stringData Type: numeric
Default Value: 900000
Range: -1 to 2147483647
Data Type: string
Default Value: groonga.log
ALERT: Alert messages, such as internal errors.CRIT: Critical error messages, such as deadlocks.
ERROR: Errors, such as API errors.
WARNING: Warnings, such as invalid arguments.
NOTICE: Notices, such as a change in configuration or a status change.
INFO: Information messages, such as file system operations.
DEBUG: Debug messages, suggested for developers or testers.
DUMP: Dump messages.
Command line: --mroonga-log-level=value
Scope: Global
Dynamic: Yes
Data Type: enum
Default Value: NOTICE
Data Type: numeric
Default Value: 0
Range: -1 to 9223372036854775807
Data Type: numeric
Default Value: 1000
Range: -1 to 2147483647
Data Type: string
Default Value: (Empty string)
Introduced:
Data Type: string
Default Value: `` (white space)
stringSimilar to mroonga_snippet, this function generates HTML-formatted snippets, automatically wrapping matched keywords in tags for web display.
mroonga_snippet_html is a user-defined function (UDF) included with the Mroonga storage engine. It provides a keyword with surrounding text, or the keyword in context. It is still considered experimental. See Creating Mroonga User-Defined Functions for details on creating this UDF if required.
This page is licensed: CC BY-SA / Gnu FDL