THEMES
Use the CTX_DOC.THEMES procedure to generate a list of themes for a document. You can store each theme as a row in either a result table or an in-memory PL/SQL table that you specify.
Syntax 1: In-Memory Table Storage
CTX_DOC.THEMES(
index_name IN VARCHAR2,
textkey IN VARCHAR2,
restab IN OUT NOCOPY THEME_TAB,
full_themes IN BOOLEAN DEFAULT FALSE,
num_themes IN NUMBER DEFAULT 50,
use_saved_copy IN NUMBER DEFAULT CTX_DOC.SAVE_COPY_FALLBACK);
Syntax 2: Result Table Storage
CTX_DOC.THEMES(
index_name IN VARCHAR2,
textkey IN VARCHAR2,
restab IN VARCHAR2,
query_id IN NUMBER DEFAULT 0,
full_themes IN BOOLEAN DEFAULT FALSE,
num_themes IN NUMBER DEFAULT 50,
use_saved_copy IN NUMBER DEFAULT CTX_DOC.SAVE_COPY_FALLBACK);
index_name
Specify the name of the index for the text column.
textkey
Specify the unique identifier (usually the primary key) for the document.
The textkey parameter can be as follows:
-
A single column primary key value
-
An encoded specification for a composite (multiple column) primary key. When textkey is a composite key, you must encode the composite
textkeystring using theCTX_DOC.PKENCODEprocedure. -
The rowid of the row containing the document
Toggle between primary key and rowid identification using CTX_DOC.SET_KEY_TYPE.
restab
You can specify this procedure to store results to either a table or to an in-memory PL/SQL table.
To store results in a table, specify the name of the table.
See Also: “Theme Table” in Oracle Text Result Tables
To store results in an in-memory table, specify the name of the in-memory table of type THEME_TAB. The THEME_TAB datatype is defined as follows:
type theme_rec is record (
theme varchar2(2000),
weight number
);
type theme_tab is table of theme_rec index by binary_integer;
CTX_DOC.THEMES clears the THEME_TAB you specify before the operation.
query_id
Specify the identifier used to identify the row(s) inserted into restab.
full_themes
Specify whether this procedure generates a single theme or a hierarchical list of parent themes (full themes) for each document theme.
Specify TRUE for this procedure to write full themes to the THEME column of the result table.
Specify FALSE for this procedure to write single theme information to the THEME column of the result table. This is the default.
num_themes
Specify the maximum number of themes to retrieve. For example, if you specify 10, then up to the first 10 themes are returned for the document. The default is 50.
If you specify 0 or NULL, then this procedure returns all themes in a document. If the document contains more than 50 themes, then only the first 50 themes show conceptual hierarchy.
use_saved_copy
Specify whether to refer to the $D table to fetch the copy of the document, and what action to take when the copy of the document is not available in the $D table.
You can specify one of the following values for the use_saved_copy parameter:
-
CTX_DOC.SAVE_COPY_FALLBACK: Fetch the copy of the document from the $D table. If the copy of the document is not present in the $D table, then fetch the document from the data store. -
CTX_DOC.SAVE_COPY_ERROR: Fetch the copy of the document from the $D table. If the copy of the document is not present in the $D table, then show an error message. Specify this value when you want to implement a specific fallback logic when the copy of the document is not available in the $D table. -
CTX_DOC.SAVE_COPY_IGNORE: Always fetch the document from the data store.
The default value is CTX_DOC.SAVE_COPY_FALLBACK.
Examples
In-Memory Themes
The following example generates the first 10 themes for document 1 and stores them in an in-memory table called the_themes. The example then loops through the table to display the document themes.
declare
the_themes ctx_doc.theme_tab;
begin
ctx_doc.themes('myindex','1',the_themes, num_themes=>10);
for i in 1..the_themes.count loop
dbms_output.put_line(the_themes(i).theme||':'||the_themes(i).weight);
end loop;
end;
Theme Table
The following example creates a theme table called CTX_THEMES:
create table CTX_THEMES (query_id number,
theme varchar2(2000),
weight number);
Single Themes
To obtain a list of up to the first 20 themes, where each element in the list is a single theme, enter a statement like the following example:
begin
ctx_doc.themes('newsindex','34','CTX_THEMES',1,full_themes => FALSE,
num_themes=> 20);
end;
Full Themes
To obtain a list of the top 20 themes, where each element in the list is a hierarchical list of parent themes, enter a statement like the following example:
begin
ctx_doc.themes('newsindex','34','CTX_THEMES',1,full_themes => TRUE, num_
themes=>20);
end;