3.6 Wordlist attributes
The wordlist attribute of Oracle full-text search is used to set fuzzy queries and root queries. The wordlist attribute also supports
For subqueries and prefix queries, the oracle wordlist attribute is only basic_wordlist (Original: Use the wordlist
Preference to enable the query options such as stemming, fuzzy matching for your language. You
Can also use the wordlist preference to enable substring and prefix indexing, which improves
Performance for wildcard queries with CONTAINS and CATSEARCH .)
3.6.1 example:
Create table my_word (id number, docs varchar2 (1000 ));
Insert into my_word values (1, Specify the stemmer used for word stemming in Text queries );
Insert into my_word values (2, Specify which fuzzy matching routines are used for
Column );
Insert into my_word values (3, Fuzzy matching is currently supported for English );
Insert into my_word values (4, Specify a default lower limit of fuzzy score. Specify
Number between 0 and 80 );
Insert into my_word values (5, Specify TRUE for Oracle Text to create a substring index
Matched .);
Commit;
/
-- Create a wordlist
Begin
Ctx_ddl.drop_preference (mywordlist );
Ctx_ddl.create_preference (mywordlist, basic_wordlist );
Ctx_ddl.set_attribute (mywordlist, fuzzy_match, english); -- fuzzy match, english
Ctx_ddl.set_attribute (mywordlist, fuzzy_score, 0); -- match score
Ctx_ddl.set_attribute (mywordlist, fuzzy_numresults, 5000 );
Ctx_ddl.set_attribute (mywordlist, substring_index, true); -- left query, applicable to % to, % to %
Ctx_ddl.set_attribute (mywordlist, stemmer, english); -- root
Ctx_ddl.set_attribute (mywordlist, prefix_index, true); -- right query, t0 %
End;
Create index indx_m_word on my_word (docs) indextype is ctxsys. context
Parameters (wordlist mywordlist );
-- Example
Select docs from my_word where contains (docs, $ match)> 0; -- Root Query
Select docs from my_word where contains (docs, MA %)> 0; -- match Query
3.6.2 example on document
Create table quick (quick_id number primary key, text varchar (80 ));
--- Insert a row with 10 expansions for tire %
Insert into quick (quick_id, text)
Values (1, tire tirea tireb tirec tired tiree tiref tireg tireh tirei tirej );
Commit;
/
Begin
Ctx_Ddl.Create_Preference (wildcard_pref, BASIC_WORDLIST );
Ctx_ddl.set_attribute (wildcard_pref, wildcard_maxterms, 100 );
End;
/
Create index wildcard_idx on quick (text) indextype is ctxsys. context
Parameters (Wordlist wildcard_pref );
Select quick_id from quick where contains (text, tire %)> 0;
Drop index wildcard_idx;
Begin
Ctx_Ddl.Drop_Preference (wildcard_pref );
Ctx_Ddl.Create_Preference (wildcard_pref, BASIC_WORDLIST );
Ctx_ddl.set_attribute (wildcard_pref, wildcard_maxterms, 5); -- limit the maximum number of matches, as shown in figure
If this quantity is exceeded, an error is returned during the query.
End;
/
Create index wildcard_idx on quick (text) indextype is ctxsys. context
Parameters (Wordlist wildcard_pref );
Select quick_id from quick where contains (text, tire %)> 0;
3.6.3. Reference script
-- Create a wordlist
Begin
Ctx_ddl.create_preference (mywordlist, BASIC_WORDLIST );
Ctx_ddl.set_attribute (mywordlist, PREFIX_INDEX, TRUE); -- Define the wordlist Parameter
End;
-- Delete wordlist
Begin
Ctx_ddl.drop_preference (mywordlist );