DB2 Text Extender
IBM propose une extension à DB2 : DB2 Text Extender.
Vous devez installer 5722DE1 *BASE et option 1, 5733XT1(option 7) ou 5761XT2
Ainsi que les options 13 , 33 et 39 de 57xxSS1 et 51 de 57xxWDS
Ensuite :
1/ Attribuer un profil de groupe supplémentaire
•QDESADM à toute personne devant faire de l'administration
•QDESUSR à toute autre personne devant utiliser le produit2/ Mettre en place les variables d'environnement suivantes (vous pouvez lancer QDB2TX/TXPROFILE)
- IMOCONFIGSRV : /QIBM/UserData/DB2Extenders/Text/instance
- IMOCONFIGCL : /QIBM/UserData/DB2Extenders/Text/instance
- NLSPATH : '/QIBM/ProdData/IMO/MRI2924/%N'
3/ Créer l'instance (une seule fois) du serveur par CALL QDB2TX/TXICRT (TXIDROP pour la supprimer)
4/ lancer le serveur par CALL QDB2TX/TXSTART (TXSTOP pour arrêter)
Les autres commandes se lancent depuis ma ligne de commande DB2TX, pour cela deux possibilités :
ADDLNK OBJ('/QSYS.LIB/QDB2TX.LIB/DB2TX.PGM) NEWLNK('/usr/bin/db2tx')
CHGOWN OBJ('/usr/bin/db2tx') NEWOWN(QDESUSR) SYMLNK(*YES)
lancez QSH (strsqh) puis tapez db2txt
![]()
5/ Initialisez le produit (une seule fois), par :
ENABLE SERVER FOR DB2TEXT
en V5R40, voyez l'APAR SE37329
6/ Vérifiez tout cela par CALL QDB2TX/TXVERIFY
Vous êtes prêts, vous pouvez alors installer une base de test par CALL QDB2TX/TXSAMPLE
ce CL va vous créer une table SAMPLE dans DB2TX et indexer la zone commentaire suivant plusieurs critères :
Commandes DB2TX :
Coded character set ID (CCSID) = 297 |
Database Connection Information Database product = AS 06010 SQL authorization ID = QSECOFR Local database alias = AS400 The database is enabled for DB2 Text Extender Table DB2TX.SAMPLE is enabled as a multi-index table TextColumnName HandleColumnName comment H_L comment H_N comment H_NCE |
Exemple : enable text column bdvin.producteurs pr_avis HANDLE pr_avis_hl
INDEXTYPE LINGUISTIC
Fonctions intégrées au produit
(localisée dans DB2TX, vous pouvez utiliser
SET CURRENT FUNCTION PATH = DB2TX, pour ne pas qualifier)
RECHERCHE :
Syntaxe des expressions de recherche :
===========Exemples=====================================================
CALL QDB2TX/TXSAMPLE : créé la base d'exemple, avec ces comamndes :
RUNSQLSTM SRCFILE(QDB2TX/SAMPLES) SRCMBR(DESCSAMP) NAMING(*SQL)
/* pour infos, l'ordre SQL
create table db2tx.sample
(
docid VARCHAR(30),
author VARCHAR(50),
subject VARCHAR(100),
date TIMESTAMP,
"comment" VARCHAR(20000)
);
*/
CPYFRMIMPF ... (pour remplir la table SAMPLE)
/* création des index */
CALL PGM(QDB2TX/DB2TX) PARM('enable text column db2tx.sample +
"comment" handle h_l CCSID 500 LANGUAGE US_ENGLISH +
indextype linguistic updateindex update')
CALL PGM(QDB2TX/DB2TX) PARM('enable text column db2tx.sample +
"comment" handle h_n CCSID 500 LANGUAGE US_ENGLISH +
indextype ngram updateindex update')
CALL PGM(QDB2TX/DB2TX) PARM('enable text column db2tx.sample +
"comment" handle h_nce CCSID 500 LANGUAGE US_ENGLISH +
indextype ngram indexoption case_enabled updateindex update')
CALL PGM(QDB2TX/DB2TX) PARM('enable text column db2tx.sample +
"comment" handle h_pn CCSID 500 LANGUAGE US_ENGLISH +
indextype precise indexoption normalized updateindex update')
CALL PGM(QDB2TX/DB2TX) PARM('enable text column db2tx.sample +
"comment" handle h_p CCSID 500 LANGUAGE US_ENGLISH +
indextype precise updateindex update')
A suivre, quelques exemples de requêtes SQL sur cette base (convention
d'appellation *SQL)
N'oubliez pas, avant de passer ces requêtes, de vous associer un profil
de
groupe (QDESADM ou QDESUSR)
et de passer la commande CALL QDB2TX/TXPROFILE pour les variables d'environnement
-- ------------------------------------------------------------------- -- CONTAINS -- ------------------------------------------------------------------- -- Indextype : PRECISE -- ------------------------------------------------------------------- select docid,subject from db2tx.sample where db2tx.contains(h_p, 'resultlimit 1 "VisualAge"') = 1
select docid,subject from db2tx.sample where db2tx.contains(h_p, '"VisualAge"') = 1
select docid,author from db2tx.sample where db2tx.contains(h_p, '"Sun Solaris"') = 1
-- ------------------------------------------------------------------- -- Indextype : LINGUISTIC -- ------------------------------------------------------------------- select docid from db2tx.sample where db2tx.contains(h_l, '"VisualAge" | ("columns" & "cics") & "cforum"') =1
select docid from db2tx.sample where db2tx.contains(h_l, '"visualage" IN SAME SENTENCE AS "question"') = 1
select docid from db2tx.sample where db2tx.contains(h_l, '"VisualAge" IN SAME PARAGRAPH AS "SQLDA"') = 1
select docid from db2tx.sample where db2tx.contains(h_l, 'SYNONYM FORM OF "response"') = 1
select docid from db2tx.sample where db2tx.contains(h_l, '"number$_of$_tablespac%" ESCAPE "$"' ) = 1
select docid from db2tx.sample where db2tx.contains(h_l, '"%cu_enta%n"' ) = 1
select docid from db2tx.sample where db2tx.contains(h_l, 'SOUNDS LIKE "snappshot" | SOUNDS LIKE "drawbeck"') = 1
select docid from db2tx.sample where db2tx.contains(h_l, 'IS ABOUT "anything about I/O parallelism"') = 1
select docid from db2tx.sample where db2tx.contains(h_l, 'IS ABOUT SYNONYM FORM OF "I am looking for documents about books"' ) = 1
select docid from db2tx.sample where db2tx.contains(h_l, 'THESAURUS "desthes" COUNT "1" EXPAND "NT" TERM OF "business" ' ) = 1 -- ------------------------------------------------------------------- -- Indextype : NGRAM -- ------------------------------------------------------------------- select docid from db2tx.sample where db2tx.contains(h_n, 'STEMMED FORM OF "find"' ) = 1
select docid from db2tx.sample where db2tx.contains(h_n, 'FUZZY FORM OF 1 "netbs"' ) = 1 -- ------------------------------------------------------------------- -- Indextype : NGRAM , INDEXOPTION: CASE_ENABLED -- ------------------------------------------------------------------- select docid from db2tx.sample where db2tx.contains(h_nce, 'PRECISE FORM OF "Support"' ) = 1 -- ------------------------------------------------------------------- -- RANK -- ------------------------------------------------------------------- select docid from db2tx.sample where db2tx.rank(h_l, 'SOUNDS LIKE "snappshot" | SOUNDS LIKE "drawbeck"') > 0 -- ------------------------------------------------------------------- -- NO_OF_MATCHES -- ------------------------------------------------------------------- with temptable(docid, subject, matches) as ( select docid, subject, no_of_matches(h_l,'"AIX" | "DB/2"') from db2tx.sample) select * from temptable where matches > 0 -- -------------------------------------------------------------------