Skip to content

Commit 6f67d05

Browse files
committed
Oracle text preferences
1 parent 0940a2b commit 6f67d05

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

oracle/dev/oracle-text-context-index.sql

+22-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ CREATE INDEX <index-name>
33
ON <table-name> (<column-name>)
44
INDEXTYPE IS CTXSYS.CONTEXT
55
PARAMETERS ('DATASTORE <datastore-name>
6-
STOPLIST <stoplist-name>
7-
WORDLIST <wordlist-name>')
6+
WORDLIST <wordlist-name>
7+
LEXER <lexer-name>
8+
STOPLIST <stoplist-name>')
89

910
-- Synchronize index contents
1011
exec CTX_DDL.SYNC_INDEX(:index_name);
@@ -14,19 +15,35 @@ exec CTX_DDL.OPTIMIZE_INDEX(:index_name, 'REBUILD');
1415
alter index <index-name> rebuild;
1516

1617
-- Parameters
18+
-- Datastore — indexing more than one column or function
19+
-- Stoplist — list of tokens to ignore
20+
-- Wordlist — weird preferences (fuzzy search, substring indexing, etc)
21+
-- Lexer - token preferences (printjoins, etc)
22+
BEGIN
23+
CTX_DDL.CREATE_PREFERENCE(:wordlist_name, 'BASIC_WORDLIST');
24+
CTX_DDL.SET_ATTRIBUTE(:wordlist_name, 'SUBSTRING_INDEX', 'YES');
25+
END;
26+
/
27+
28+
BEGIN
29+
CTX_DDL.CREATE_PREFERENCE(:lexer_name, 'BASIC_LEXER');
30+
-- do not 'tokenize' by '/'
31+
CTX_DDL.SET_ATTRIBUTE(:lexer_name, 'PRINTJOINS', '/');
32+
END;
33+
/
1734

1835
-- Commands for creating and dropping stoplists
1936
BEGIN
2037
CTX_DDL.CREATE_STOPLIST(
2138
stoplist_name => :stoplist_name,
2239
stoplist_type => 'BASIC_STOPLIST');
2340
END;
24-
41+
/
2542
BEGIN
2643
CTX_DDL.DROP_STOPLIST(
2744
stoplist_name => :stoplist_name);
2845
END;
29-
46+
/
3047
-- Create and index without a stoplist first.
3148
-- Check the most common tokens in dr$<index-name>$i.
3249
-- Add stopwords
@@ -35,7 +52,7 @@ BEGIN
3552
stoplist_name => :stoplist_name,
3653
stopword => :token);
3754
END;
38-
55+
/
3956
-- If you want to check existing stopwords, query CTX_STOPWORDS
4057
select *
4158
from CTX_STOPWORDS

0 commit comments

Comments
 (0)