Oracle8i interMedia Text Migration
Release 2 (8.1.6)

Part Number A77061-01

Library

Product

Contents

Index

Go to previous page Go to beginning of chapter Go to next page

Querying, 8 of 12


Max and First/Next Operators

The max and first/next result-set operators are no longer supported in interMedia Text 8.1.

Pre-8.1 Method

Max

The Max operator is used to obtain a given number of the highest scoring documents in a query result set. For example, to obtain the twenty highest scoring documents that contain the word dog, you can write:

'dog:20'

First/Next

The first/next operator is used to obtain a range of documents in an unsorted query result-set. For example, to obtain documents 11 through twenty that contain the word dog, you can write:

'dog#11-20'

8.1 Method

The max and first/next operators are not supported in interMedia Text 8.1. You can use a cursor query optimized for response time in PL/SQL to achieve the results for a max or first/next type of query.

Solution for Max

A query optimized for response time provides a fast solution for when you need the highest scoring documents from a hitlist.

The example below returns the first twenty hits to standard out. This example uses the FIRST_ROWS hint and a cursor.

declare 
cursor c is  
  select /*+ FIRST_ROWS */ title, score(1) score 
    from news  
   where contains(txt_col, 'dog', 1) > 0  
   order by score(1) desc; 
begin 
  for c1 in c 
  loop 
    dbms_output.put_line(c1.score||':'||substr(c1.title,1,50)); 
    exit when c%rowcount = 20; 
  end loop; 
end; 
/ 

See Also:

To learn more about optimizing queries for response time, see the Oracle8i interMedia Text Reference

Solution for First/Next

A query optimized for response time provides a fast solution for when you need a range of documents from a hitlist sorted by score.

The solution is similar to the max doc solution in that it uses the FIRST_ROWS hint in a cursor. The code loops through the cursor to process only the hits in the required range. The example below returns the sorted documents 11 to 20 to standard out.

declare 
cursor c is  
  select /*+ FIRST_ROWS */ title, score(1) score 
    from news  
   where contains(txt_col, 'dog', 1) > 0  
   order by score(1) desc; 
begin 
  for c1 in c 
  loop 
    if (c%rowcount > 10) then 
      dbms_output.put_line(c1.score||':'||substr(c1.title,1,50)); 
    end if; 
    exit when c%rowcount = 20; 
  end loop; 
end; 
/

See Also:

To learn more about optimizing queries for response time, see the Oracle8i interMedia Text Reference


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.

Library

Product

Contents

Index