Pas de résultat avec FULLTEXT SEARCH
Bonjour,
MariaDB 10.1.37 sous Debian 9.8
J'ai développé un petit module de recherche dans un site qui fonctionne très bien jusqu'à ce qu'un utilisateur découvre une "anomalie"...
En résumé, j'ai une table "document" contenant 2 champs ayant un index FULLTEXT (intitule et commentaire) dans une base InnoDB
La recherche FTS (Fulltext search) ne retourne aucun résultat avec le mot clé "organigramme" contrairement à LIKE !
Démonstration :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| MariaDB [ged]> SELECT id, intitule, commentaire
-> FROM document
-> WHERE intitule LIKE '%organigramme%';
+-----+------------------------------------------------+--------------+
| id | intitule | commentaire |
+-----+------------------------------------------------+--------------+
| 9 | Organigramme ESAT | NULL |
| 10 | Organigramme ESAT anonymé | NULL |
| 52 | Organigramme Habitats | NULL |
| 74 | Organigramme IME | NULL |
| 75 | Organigramme Unité d enseignement maternelle | NULL |
| 102 | Organigramme MAS | NULL |
| 139 | Organigramme SESSAD | NULL |
| 150 | Organigramme DAF simplifié | NULL |
| 209 | Organigramme général | NULL |
| 309 | Organigramme Habitats | organigramme |
+-----+------------------------------------------------+--------------+
10 rows in set (0.00 sec) |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| MariaDB [ged]> SELECT id, intitule, commentaire,
-> MATCH(intitule) AGAINST ('organigramme*' IN BOOLEAN MODE) AS score_intitule,
-> MATCH(commentaire) AGAINST ('organigramme*' IN BOOLEAN MODE) AS score_commentaire
-> FROM document
-> WHERE
-> MATCH(intitule) AGAINST ('organigramme*' IN BOOLEAN MODE) OR
-> MATCH(commentaire) AGAINST ('organigramme*' IN BOOLEAN MODE) OR
-> intitule LIKE '%organigramme%';
+-----+------------------------------------------------+--------------+----------------+-------------------+
| id | intitule | commentaire | score_intitule | score_commentaire |
+-----+------------------------------------------------+--------------+----------------+-------------------+
| 9 | Organigramme ESAT | NULL | 0 | 0 |
| 10 | Organigramme ESAT anonymé | NULL | 0 | 0 |
| 52 | Organigramme Habitats | NULL | 0 | 0 |
| 74 | Organigramme IME | NULL | 0 | 0 |
| 75 | Organigramme Unité d enseignement maternelle | NULL | 0 | 0 |
| 102 | Organigramme MAS | NULL | 0 | 0 |
| 139 | Organigramme SESSAD | NULL | 0 | 0 |
| 150 | Organigramme DAF simplifié | NULL | 0 | 0 |
| 209 | Organigramme général | NULL | 0 | 0 |
| 309 | Organigramme Habitats | organigramme | 0 | 0 |
+-----+------------------------------------------------+--------------+----------------+-------------------+
10 rows in set (0.00 sec) |
=> les scores restent à 0 malgré la présence du mot "organigramme"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| MariaDB [ged]> SELECT id, intitule, commentaire,
-> MATCH(intitule) AGAINST ('*gra*' IN BOOLEAN MODE) AS score_intitule,
-> MATCH(commentaire) AGAINST ('*gra*' IN BOOLEAN MODE) AS score_commentaire
-> FROM document
-> WHERE
-> MATCH(intitule) AGAINST ('*gra*' IN BOOLEAN MODE) OR
-> MATCH(commentaire) AGAINST ('*gra*' IN BOOLEAN MODE) OR
-> intitule LIKE '%gra%';
+-----+----------------------------------------------------------------------------------+--------------+-------------------+
| id | intitule | commentaire | score_intitule |
+-----+----------------------------------------------------------------------------------+--------------+-------------------+
| 9 | Organigramme ESAT | NULL | 0 |
| 10 | Organigramme ESAT anonymé | NULL | 0 |
| 52 | Organigramme Habitats | NULL | 0 |
| 74 | Organigramme IME | NULL | 0 |
| 75 | Organigramme Unité d enseignement maternelle | NULL | 0 |
| 102 | Organigramme MAS | NULL | 0 |
| 139 | Organigramme SESSAD | NULL | 0 |
| 150 | Organigramme DAF simplifié | NULL | 0 |
| 181 | Cartographie des emplois, tendances et perspectives des emplois Edition 2018 | NULL | 0 |
| 209 | Organigramme général | NULL | 0 |
| 226 | Formulaire de signalement des évènements indésirables graves | EIG | 4.068423271179199 |
| 230 | Notice pour rédiger et adresser un signalement d évènement indésirable grave | NULL | 4.068423271179199 |
| 268 | Cartographie générale des processus | NULL | 0 |
| 269 | Cartographie détaillée des processus | NULL | 0 |
| 275 | Cartographie des processus | NULL | 0 |
| 282 | Formulaire de transmission d un Événement Indésirable Grave | EIG ARS | 4.068423271179199 |
| 309 | Organigramme Habitats | organigramme | 0 |
| 313 | Organigramme IME | NULL | 0 |
| 314 | Organigramme IME | NULL | 0 |
+-----+----------------------------------------------------------------------------------+--------------+-------------------+
19 rows in set (0.00 sec) |
=> certains scores fonctionnent avec "gra".
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| MariaDB [ged]> SELECT id, intitule, commentaire,
-> MATCH(intitule) AGAINST ('esat' IN BOOLEAN MODE) AS score_intitule,
-> MATCH(commentaire) AGAINST ('esat' IN BOOLEAN MODE) AS score_commentaire
-> FROM document
-> WHERE
-> MATCH(intitule) AGAINST ('esat' IN BOOLEAN MODE) OR
-> MATCH(commentaire) AGAINST ('esat' IN BOOLEAN MODE);
+-----+-----------------------------------------+-------------+-------------------+-------------------+
| id | intitule | commentaire | score_intitule | score_commentaire |
+-----+-----------------------------------------+-------------+-------------------+-------------------+
| 2 | Livret d accueil ESAT | NULL | 1.534828782081604 | 0 |
| 3 | Règlement de fonctionnement ESAT | NULL | 1.534828782081604 | 0 |
| 6 | Diminution de 9 places ESAT | NULL | 1.534828782081604 | 0 |
| 7 | Augmentation de 7 places ESAT | NULL | 1.534828782081604 | 0 |
| 9 | Organigramme ESAT | NULL | 1.534828782081604 | 0 |
| 10 | Organigramme ESAT anonymé | NULL | 1.534828782081604 | 0 |
| 11 | Projet d Etablissement ESAT 2015/2020 | NULL | 1.534828782081604 | 0 |
| 13 | Plaquette broderie ESAT | NULL | 1.534828782081604 | 0 |
| 14 | Plaquette ESAT Commercial | NULL | 1.534828782081604 | 0 |
| 17 | Règlement intérieur du CVS ESAT | NULL | 1.534828782081604 | 0 |
| 19 | Rapport d évaluation externe ESAT 2014 | NULL | 1.534828782081604 | 0 |
| 20 | Rapport d évaluation interne ESAT | NULL | 1.534828782081604 | 0 |
| 53 | Trame de PAP Hébergement ESAT | NULL | 1.534828782081604 | 0 |
| 302 | Logo ESAT jpeg | NULL | 1.534828782081604 | 0 |
| 303 | Logo ESAT pdf | NULL | 1.534828782081604 | 0 |
+-----+-----------------------------------------+-------------+-------------------+-------------------+
15 rows in set (0.00 sec) |
=> tout est ok avec la recherche "esat"
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| MariaDB [ged]> SHOW VARIABLES LIKE "%version%";
+-------------------------+--------------------------+
| Variable_name | Value |
+-------------------------+--------------------------+
| innodb_version | 5.6.41-84.1 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 10.1.37-MariaDB-0+deb9u1 |
| version_comment | Debian 9.6 |
| version_compile_machine | x86_64 |
| version_compile_os | debian-linux-gnu |
| version_malloc_library | system jemalloc |
| version_ssl_library | YaSSL 2.4.4 |
| wsrep_patch_version | wsrep_25.23 |
+-------------------------+--------------------------+
10 rows in set (0.00 sec) |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| MariaDB [ged]> SHOW VARIABLES LIKE 'innodb_ft%';
+---------------------------------+------------+
| Variable_name | Value |
+---------------------------------+------------+
| innodb_ft_aux_table | |
| innodb_ft_cache_size | 8000000 |
| innodb_ft_enable_diag_print | OFF |
| innodb_ft_enable_stopword | OFF |
| innodb_ft_max_token_size | 10 |
| innodb_ft_min_token_size | 0 |
| innodb_ft_num_word_optimize | 2000 |
| innodb_ft_result_cache_limit | 2000000000 |
| innodb_ft_server_stopword_table | |
| innodb_ft_sort_pll_degree | 2 |
| innodb_ft_total_cache_size | 640000000 |
| innodb_ft_user_stopword_table | |
+---------------------------------+------------+
12 rows in set (0.00 sec) |
Le fichier de conf :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| root@debian:~# nano /etc/mysql/my.cnf
#
# * Full Text Search
#
ft-max-word-len = 17
ft-min-word-len = 2
ft-stopword-file = ""
innodb-ft-enable-stopword = off
innodb-ft-max-token-size = 10
innodb-ft-min-token-size = 0
#init-connect = 'SET NAMES latin1 COLLATE latin1_general_ci' |
J'ai essayé de reconstruire les index...
Code:
1 2 3 4
| DROP INDEX `search_intitule` ON document;
DROP INDEX `search_commentaire` ON document;
ALTER TABLE `document` ADD FULLTEXT KEY `search_intitule` (`intitule`);
ALTER TABLE `document` ADD FULLTEXT KEY `search_commentaire` (`commentaire`); |
... sans succès :?
A priori il n'y a "que" ce mot clé "organigramme"... mais pourquoi !!!!!!!!!!!!!!!!!!??????? :aie::roll:
Merci pour votre aide