Index Rules to Categorize New Documents

Once the rules are generated, you can test them by first indexing them and then using MATCHES to classify new documents. The process is as follows:

  1. Index the rules to create the CTXRULE index

    Use CREATE INDEX to create the CTXRULE index on the previously generated rules:

    create index rules_idx on rules (rule_text) indextype is ctxsys.ctxrule;
    
  2. Test an incoming document using MATCHES

    set serveroutput on;
    
    declare
       incoming_doc clob;
    begin
       incoming_doc 
           := 'I have spent my entire life managing restaurants selling burgers';
       for c in 
         ( select distinct cd_description from rules, category_descriptions
           where cd_category = rule_cat_id
           and matches (rule_text, incoming_doc) > 0) loop
         dbms_output.put_line('CATEGORY: '||c.cd_description);
       end loop;
    end;
    /