Oracle8i interMedia Text Migration
Release 2 (8.1.6)

A77061-01

Library

Product

Contents

Index

Prev Up Next

Querying, 10 of 12


Counting Hits

The interMedia Text 8.1 release supports the CTX_QUERY.COUNT_HITS function, which you use in pre-8.1 to count the number of hits in a query before issuing the query. However in 8.1, you specify the index name rather than a policy. In addition, the struct_query parameter used in pre-8.1 to specify the structured predicate is obsolete.

In 8.1, to count the number of hits returned from a query with only a CONTAINS predicate, you can use CTX_QUERY.COUNT_HITS or COUNT(*) in a SELECT statement.

To count the number of hits returned from a query that contains a structured predicate, use the COUNT(*) function in a SELECT statement.

Because in-memory queries are obsolete in 8.1, the pre-8.1 procedure CTX_QUERY.COUNT_LAST procedure is also obsolete in 8.1.

Pre-8.1 Method

You count query hits with COUNT_HITS as follows:

declare count number;
begin
  count := ctx_query.count_hits(policy_name => my_pol, text_query => 'oracle',                     	
                              exact => TRUE);
 dbms_output.put_line('Number of docs with oracle:');
 dbms_output.put_line(count);
end;

8.1 Method

CONTAINS Predicate Only

To find the number of documents that contain the word oracle, you can do one of the following:

Structured Predicate

To find the number of documents returned by a query with a structured predicate, use count(*) as follows:

SELECT count(*) FROM news WHERE CONTAINS(text, 'oracle', 1) > 0 and author = 
'jones';

Prev Up Next
Oracle
Copyright © 1999 Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index