Monday, January 5, 2009

Querying with MATCHES [CTXRULE INDEX]

When you create an index of type CTXRULE, you must use the MATCHES operator to classify your documents.

SELECT classification FROM querytable WHERE MATCHES(query_string,:doc_text) > 0;

Putting it all-together,

create table queries (query_id number,query_string varchar2(80));
insert into queries values (1, 'oracle');
insert into queries values (2, 'larry or ellison');
insert into queries values (3, 'oracle and text');
insert into queries values (4, 'market share');
create index queryx on queries(query_string)
indextype is ctxsys.ctxrule;

select query_id from queries where matches(query_string, 'Oracle announced that its market share in databases increased over the last year.')>0

This query will return queries 1 (the word oracle appears in the document) and 4 (the phrase market share appears in the document).

No comments:

search engine

Custom Search