Oracle8i interMedia Text Migration Release 2 (8.1.6) Part Number A77061-01 |
|
Querying, 10 of 12
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.
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;
To find the number of documents that contain the word oracle, you can do one of the following:
SELECT count(*) FROM news WHERE CONTAINS(text, 'oracle', 1) > 0;
declare count number; begin count := ctx_query.count_hits(index_name => my_index, text_query => 'oracle', exact => TRUE); dbms_output.put_line('Number of docs with oracle:'); dbms_output.put_line(count); end;
See Also:
To learn more about the syntax of CTX_QUERY.COUNT_HITS, see the Oracle8i interMedia Text Reference. |
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';
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|