|
|
@@ -53,14 +53,14 @@ Now let's look at our RT index:
|
|
|
.. code-block:: mysql
|
|
|
|
|
|
mysql> DESCRIBE testrt;
|
|
|
- +---------+--------+
|
|
|
- | Field | Type |
|
|
|
- +---------+--------+
|
|
|
- | id | bigint |
|
|
|
- | title | field |
|
|
|
- | content | field |
|
|
|
- | gid | uint |
|
|
|
- +---------+--------+
|
|
|
+ +----------+--------+------------+
|
|
|
+ | Field | Type | Properties |
|
|
|
+ +----------+--------+------------+
|
|
|
+ | id | bigint | |
|
|
|
+ | title | field | stored |
|
|
|
+ | content | field | stored |
|
|
|
+ | gid | uint | |
|
|
|
+ +----------+--------+------------+
|
|
|
4 rows in set (0.00 sec)
|
|
|
|
|
|
As the RT indexes start empty, let's add some data into it first
|
|
|
@@ -91,14 +91,14 @@ Fulltext searches are done with the special clause MATCH, which is the main work
|
|
|
.. code-block:: mysql
|
|
|
|
|
|
mysql> SELECT * FROM testrt WHERE MATCH('list of laptops');
|
|
|
- +------+------+
|
|
|
- | id | gid |
|
|
|
- +------+------+
|
|
|
- | 1 | 10 |
|
|
|
- | 2 | 10 |
|
|
|
- | 3 | 20 |
|
|
|
- | 5 | 30 |
|
|
|
- +------+------+
|
|
|
+ +------+------+-------------------------------------+---------------------------+
|
|
|
+ | id | gid | title | content |
|
|
|
+ +------+------+-------------------------------------+---------------------------+
|
|
|
+ | 1 | 10 | List of HP business laptops | Elitebook Probook |
|
|
|
+ | 2 | 10 | List of Dell business laptops | Latitude Precision Vostro |
|
|
|
+ | 3 | 20 | List of Dell gaming laptops | Inspirion Alienware |
|
|
|
+ | 5 | 30 | List of ASUS ultrabooks and laptops | Zenbook Vivobook |
|
|
|
+ +------+------+-------------------------------------+---------------------------+
|
|
|
4 rows in set (0.00 sec)
|
|
|
|
|
|
|
|
|
@@ -110,12 +110,12 @@ Now let's add some filtering and more ordering:
|
|
|
.. code-block:: mysql
|
|
|
|
|
|
mysql> SELECT *,WEIGHT() FROM testrt WHERE MATCH('list of laptops') AND gid>10 ORDER BY WEIGHT() DESC,gid DESC;
|
|
|
- +------+------+----------+
|
|
|
- | id | gid | weight() |
|
|
|
- +------+------+----------+
|
|
|
- | 5 | 30 | 2334 |
|
|
|
- | 3 | 20 | 2334 |
|
|
|
- +------+------+----------+
|
|
|
+ +------+------+-------------------------------------+---------------------+----------+
|
|
|
+ | id | gid | title | content | weight() |
|
|
|
+ +------+------+-------------------------------------+---------------------+----------+
|
|
|
+ | 5 | 30 | List of ASUS ultrabooks and laptops | Zenbook Vivobook | 2334 |
|
|
|
+ | 3 | 20 | List of Dell gaming laptops | Inspirion Alienware | 2334 |
|
|
|
+ +------+------+-------------------------------------+---------------------+----------+
|
|
|
2 rows in set (0.00 sec)
|
|
|
|
|
|
|
|
|
@@ -127,14 +127,14 @@ The search above does a simple matching, where all words need to be present. But
|
|
|
.. code-block:: mysql
|
|
|
|
|
|
mysql> SELECT *,WEIGHT() FROM testrt WHERE MATCH('"list of business laptops"/3');
|
|
|
- +------+------+----------+
|
|
|
- | id | gid | weight() |
|
|
|
- +------+------+----------+
|
|
|
- | 1 | 10 | 2397 |
|
|
|
- | 2 | 10 | 2397 |
|
|
|
- | 3 | 20 | 2375 |
|
|
|
- | 5 | 30 | 2375 |
|
|
|
- +------+------+----------+
|
|
|
+ +------+------+-------------------------------------+---------------------------+----------+
|
|
|
+ | id | gid | title | content | weight() |
|
|
|
+ +------+------+-------------------------------------+---------------------------+----------+
|
|
|
+ | 1 | 10 | List of HP business laptops | Elitebook Probook | 2397 |
|
|
|
+ | 2 | 10 | List of Dell business laptops | Latitude Precision Vostro | 2397 |
|
|
|
+ | 3 | 20 | List of Dell gaming laptops | Inspirion Alienware | 2375 |
|
|
|
+ | 5 | 30 | List of ASUS ultrabooks and laptops | Zenbook Vivobook | 2375 |
|
|
|
+ +------+------+-------------------------------------+---------------------------+----------+
|
|
|
4 rows in set (0.00 sec)
|
|
|
|
|
|
|
|
|
@@ -179,6 +179,7 @@ To create a new RT index, you need to define it in the manticore.conf. A simple
|
|
|
rt_attr_uint = attr2
|
|
|
}
|
|
|
|
|
|
+Remember that rt_fields are only indexed and not stored by default. If you want their values back in the results, you need to add 'stored_fields = title'.
|
|
|
To get the index online you need to either restart the daemon or send a HUP signal to it.
|
|
|
|
|
|
Using plain indexes
|
|
|
@@ -215,6 +216,7 @@ Add in your manticore.conf:
|
|
|
|
|
|
source = src1
|
|
|
path = /var/lib/manticore/data/test1
|
|
|
+ stored_fields = title, content
|
|
|
min_word_len = 1
|
|
|
|
|
|
}
|
|
|
@@ -293,14 +295,14 @@ Index is created and is ready to be used:
|
|
|
3 rows in set (0.00 sec)
|
|
|
|
|
|
mysql> SELECT * FROM test1;
|
|
|
- +------+----------+------------+
|
|
|
- | id | group_id | date_added |
|
|
|
- +------+----------+------------+
|
|
|
- | 1 | 1 | 1507904567 |
|
|
|
- | 2 | 1 | 1507904567 |
|
|
|
- | 3 | 2 | 1507904567 |
|
|
|
- | 4 | 2 | 1507904567 |
|
|
|
- +------+----------+------------+
|
|
|
+ +------+----------+------------+-----------------+---------------------------------------------------------------------------+
|
|
|
+ | id | group_id | date_added | title | content |
|
|
|
+ +------+----------+------------+-----------------+---------------------------------------------------------------------------+
|
|
|
+ | 1 | 1 | 1497982018 | test one | this is my test document number one. also checking search within phrases. |
|
|
|
+ | 2 | 1 | 1497982018 | test two | this is my test document number two |
|
|
|
+ | 3 | 2 | 1497982018 | another doc | this is another group |
|
|
|
+ | 4 | 2 | 1497982018 | doc number four | this is to test groups |
|
|
|
+ +------+----------+------------+-----------------+---------------------------------------------------------------------------+
|
|
|
4 rows in set (0.00 sec)
|
|
|
|
|
|
A quick test of a search which should match 2 terms, but not match another one:
|
|
|
@@ -308,9 +310,9 @@ A quick test of a search which should match 2 terms, but not match another one:
|
|
|
.. code-block:: mysql
|
|
|
|
|
|
mysql> SELECT * FROM test1 WHERE MATCH('test document -one');
|
|
|
- +------+----------+------------+-------+
|
|
|
- | id | group_id | date_added | tag |
|
|
|
- +------+----------+------------+-------+
|
|
|
- | 2 | 1 | 1519040667 | 2,4,6 |
|
|
|
- +------+----------+------------+-------+
|
|
|
+ +------+----------+------------+----------+-------------------------------------+
|
|
|
+ | id | group_id | date_added | title | content |
|
|
|
+ +------+----------+------------+----------+-------------------------------------+
|
|
|
+ | 2 | 1 | 1497982018 | test two | this is my test document number two |
|
|
|
+ +------+----------+------------+----------+-------------------------------------+
|
|
|
1 row in set (0.00 sec)
|