Reputation: 11874
I know I can use ctx_query.count_hits
to count the number of document matching a query,
and similarly, I can use
count(*) where CONTAINS(...)
But these are only options if I actually have a query. Those functions throw an exception if I pass an empty string as a query (thanks oracle...). So,
Is there a way to count the total number of document indexed by my oracle.text index?
Upvotes: 2
Views: 1755
Reputation: 5519
The preferred way is to use CTX_REPORT Package, either describe_index
set long 50000
select ctx_report.describe_index('MYINDEX') from dual;
will give you the number of indexed documents in docid count
column:
=========================================================================== INDEX DESCRIPTION =========================================================================== index name: "SCHEMA"."MYINDEX" index id: 1130 index type: context status: INDEXED full optimize token: full optimize count: docid count: 6909265 nextid: 6909266
Alternatively, use index_stats:
create table output (result CLOB);
declare
x clob := null;
begin
ctx_report.index_stats('MYINDEX',x);
insert into output values (x);
commit;
dbms_lob.freetemporary(x);
end;
/
set long 32000
set head off
set pagesize 10000
select * from output;
=========================================================================== STATISTICS FOR "SCHEMA"."MYINDEX" =========================================================================== indexed documents: 6,909,265
Also useful to get the size of the index:
set long 50000
select ctx_report.index_size('MYINDEX') from dual;
Upvotes: 2
Reputation: 30775
You can use the CTX... views:
select idx_name, idx_table_owner, idx_table, idx_docid_count
from ctx_user_indexes
Upvotes: 0