CREATE_POLICY
Creates a policy to use with the CTX_DOC.POLICY_* procedures and the ORA:CONTAINS function. ORA:CONTAINS is a function you use within an XPATH query expression with existsNode().
See Also: Oracle XML DB Developer’s Guide
Syntax
CTX_DDL.CREATE_POLICY(
policy_name IN VARCHAR2,
filter IN VARCHAR2 DEFAULT NULL,
section_group IN VARCHAR2 DEFAULT NULL,
lexer IN VARCHAR2 DEFAULT NULL,
stoplist IN VARCHAR2 DEFAULT NULL,
wordlist IN VARCHAR2 DEFAULT NULL);
policy_name
Specify the name for the new policy. Policy names and Text indexes share the same namespace.
filter
Specify the filter preference to use.
section_group
Specify the section group to use. You can specify any section group that is supported by CONTEXT index.
lexer
Specify the lexer preference to use. Your INDEX_THEMES attribute must be disabled.
stoplist
Specify the stoplist to use.
wordlist
Specify the wordlist to use.
Example
Create mylex lexer preference named mylex.
begin
ctx_ddl.create_preference('mylex', 'BASIC_LEXER');
ctx_ddl.set_attribute('mylex', 'printjoins', '_-');
ctx_ddl.set_attribute ( 'mylex', 'index_themes', 'NO');
ctx_ddl.set_attribute ( 'mylex', 'index_text', 'YES');
end;
Create a stoplist preference named mystop.
begin
ctx_ddl.create_stoplist('mystop', 'BASIC_STOPLIST');
ctx_ddl.add_stopword('mystop', 'because');
ctx_ddl.add_stopword('mystop', 'nonetheless');
ctx_ddl.add_stopword('mystop', 'therefore');
end;
Create a wordlist preference named ‘mywordlist’.
begin
ctx_ddl.create_preference('mywordlist', 'BASIC_WORDLIST');
ctx_ddl.set_attribute('mywordlist','FUZZY_MATCH','ENGLISH');
ctx_ddl.set_attribute('mywordlist','FUZZY_SCORE','1');
ctx_ddl.set_attribute('mywordlist','FUZZY_NUMRESULTS','5000');
ctx_ddl.set_attribute('mywordlist','SUBSTRING_INDEX','TRUE');
ctx_ddl.set_attribute('mywordlist','STEMMER','ENGLISH');
end;
exec ctx_ddl.create_policy('my_policy', NULL, NULL, 'mylex', 'mystop',
'mywordlist');
or
exec ctx_ddl.create_policy(policy_name => 'my_policy',
lexer => 'mylex',
stoplist => 'mystop',
wordlist => 'mywordlist');
Then enter the following existsNode() query with your own defined policy:
select id from xmltab
where existsNode(doc, '/book/chapter[ ora:contains(summary,"dog or cat",
"my_policy") >0 ]', 'xmlns:ora="http://xmlns.example.com/xdb" ')=1;
Update the policy with the following:
exec ctx_ddl.update_policy(policy_name => 'my_policy', lexer => 'my_new_lex');
Drop the policy with the following:
exec ctx_ddl.drop_policy(policy_name => 'my_policy');