Partitioning the Text Index

Hi,
I need to know the possibility of partitioning the oracle text index which is already been built.
Could anyone post some sample code for that?
Thanks in advance.

I thought there might be a problem with DETAIL_DATASTORE and partitioning, but it seems to work fine for me.
Are your tables range partitioned? See the testcase below, and see if you can modify it to produce the error you're seeing.
drop table pt2;
drop table pt1;
create table pt1 (
  id number   primary key,
  part_key    number,
  dummy       varchar2(1))
partition by range (part_key)
( partition p1 values less than (2),
  partition p2 values less than (maxvalue)
create table pt2 (
  id          number primary key,
  part_key    number,
  fk          number,
  line_number number,
  text        varchar2(80),
  constraint  pt2fkc foreign key (fk) references pt1(id) )
partition by range (part_key)
( partition p1 values less than (2),
  partition p2 values less than (maxvalue)
insert into pt1 values (1, 1, 'x');
insert into pt1 values (2, 2, 'x');
insert into pt2 values (1, 1, 1, 1, 'the quick brown fox ');
insert into pt2 values (2, 1, 1, 2, 'jumps over the lazy dog');
insert into pt2 values (3, 2, 2, 1, 'now is the time for all good men ');
insert into pt2 values (4, 2, 2, 2, 'to come to the aid of the party');
exec ctx_ddl.drop_preference  ('mymd')
exec ctx_ddl.create_preference('mymd', 'DETAIL_DATASTORE')
exec ctx_ddl.set_attribute    ('mymd', 'DETAIL_TABLE', 'PT2')
exec ctx_ddl.set_attribute    ('mymd', 'DETAIL_KEY',   'FK')
exec ctx_ddl.set_attribute    ('mymd', 'DETAIL_TEXT',  'TEXT')
exec ctx_ddl.set_attribute    ('mymd', 'DETAIL_LINENO','LINE_NUMBER')
create index pt_index on pt1 (dummy) indextype is ctxsys.context
parameters ('datastore mymd')
local
/I'm testing on 11.2.0.2. If this testcase gives you an error on an earlier version, it must be a bug that has been fixed.
Roger

Similar Messages

  • ERROR while syncing the Text Index

    Hi All,
    We are facing an issue while syncing the text index on the table, and the error is below,
    System error: Plsql job execution is failed with error code -20000 and error message ORA-20000: Oracle Text error: DRG-10017: you must be CTXSYS to do this: SYNC
    We have granted the USER with CTXAPP and CTXSYS roles.
    We are scheduling the SYNC from the QUARTZ Scheduler and it happens for every 5 Minutes. We are getting this error in ADHOC Basis.
    Could anyone help us in solving the issue.
    Thanks.

    Hi
    to be able to run ctx_ddl.sync_index as a database job it is necessary to have explicit grants for ctx_ddl, the inheritance via the role ctxapp does not suffice.
    SQL> grant execute on ctxsys.ctx_ddl to <user_submitting_the_job>;
    -Edwin

  • Oracle text installed but can't find anything through the text indexes

    Hello,
    i've got a Oracle 10G (10.2.0.4) database 64bit on a Windows 2003r2 64bit (sp2). I also installed the Oracle Text:
    Oracle Text
    VALID 10.2.0.4.0
    then I created some preferences and created the text indexes:
    create index afindex on docs(document) indextype is ctxsys.context parameters('storage gdoc_store SYNC (ON COMMIT)');
    so with the syn on commit, it should immediately be seen in the index.
    I have for example in 1 table 6 documents (word,pdf ...), the other has more then 64000 documents and the 3rd one more than 425000.
    In none of the 3 above, searching on text gives result after index is created. Not in the developer his program nor in sqlplus.
    searching sql for example:
    select id from docs where contains(doc,'hello')>0;
    under the c:\windows\temp, I see about 380files with drgibXXXXX, so it does index them?
    What could be the problem?
    note that I've got lots of other database where I also use Oracle text and there is no problem, only difference is the 32 <-> 64bit.
    error in ctx_index_error is :
    DRG-11207: user filter command exited with status 1
    Edited by: user12155961 on 15-apr-2010 5:33

    According to the [http://download.oracle.com/docs/cd/B19306_01/text.102/b14218/afilsupt.htm#sthref2446|10.2 docs], Auto Filter is supported on the following platforms:
    Microsoft Windows
    o Server 2003 (x86 and IA-64)
    o XP (Service Packs 1 and 2)
    o 2000 x86 (Service Pack 2)
    o NT 4.0 x86 (Intel) (Service Pack 6a)
    Sun Solaris 8.0 and 9.0
    HP-UX 11.0 and 11i, PA-RISC
    HP-UX 11i v11.23, IA-64
    IBM AIX 5.1 and 5.2L
    Red Hat Linux 7.3 and 8.0
    Red Hat Enterprise Linux AS 2.1 and 3.0 (x86)
    Red Hat Enterprise Linux AS 3.0 (IA-64)
    SuSE Linux Standard Server 8 (x86)
    Note x84 and IA-64 (Itanium 64) but not x86-64. So I suspect that you don't get the filters at all.
    If this is the case, your options are either to install a 32 bit version of Oracle for Windows (which I believe should work fine on 64 bit Windows) or to attempt to cobble the 32 bit ctxhx into your 64 bit environment. I'm sure this should be possible, but it would be unsupported and I don't have any kind of "how to" on doing it.

  • Can the text index do it for me?

    Hi all,
    I have the following requirements und question to oracle text index:
    I have saved in the VARCHAR2 column some strings:
    CREATE TABLE t1
    (STR VARCHAR2(200));
    INSERT INTO t1 (STR)
    VALUES ('Abcd');
    INSERT INTO t1 (STR)
    VALUES ('abcd');
    INSERT INTO t1 (STR)
    VALUES ('Aabcd');
    INSERT INTO t1 (STR)
    VALUES ('Abcd-ef');
    INSERT INTO t1 (STR)
    VALUES ('Abcd ef');
    INSERT INTO t1 (STR)
    VALUES ('Abcd - ef');
    INSERT INTO t1 (STR)
    VALUES ('Abcd - 12');
    INSERT INTO t1 (STR)
    VALUES ('Abcd_ef12');
    INSERT INTO t1 (STR)
    VALUES ('Abcdef');
    INSERT INTO t1 (STR)
    VALUES ('Abcdgh');
    INSERT INTO t1 (STR)
    VALUES ('Abcdij');
    INSERT INTO t1 (STR)
    VALUES ('Abcdklmnop');
    COMMIT;Then I create a text index with the following script:
    BEGIN
      CTX_DDL.CREATE_PREFERENCE('SUBSTR_PREF','BASIC_WORDLIST');
      CTX_DDL.SET_ATTRIBUTE('SUBSTR_PREF','SUBSTRING_INDEX','TRUE');
      CTX_DDL.CREATE_PREFERENCE('pj_lex', 'BASIC_LEXER');
      CTX_DDL.SET_ATTRIBUTE('pj_lex', 'PRINTJOINS', '-');
      CTX_DDL.CREATE_PREFERENCE('mcds_t1_str', 'MULTI_COLUMN_DATASTORE');
      CTX_DDL.SET_ATTRIBUTE('mcds_t1_str', 'COLUMNS', '''XZX''||STR');
    END;
    CREATE INDEX IDX_T1_STR ON T1
    (STR)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('wordlist  SUBSTRING_PREF
                LEXER     pj_lex
                DATASTORE mcds_t1_str
                memory    50m')
    NOPARALLEL;My requirements are: when I search for "abcd" (WHERE contains (STR, 'XZX'||:var1||'%') > 0):
    I should get: Abcd, abcd, Abcd-ef, Abcd ef, Abcd - ef, Abcd - 12, Abcd_ef12, but not Abcdef*, Abcdgh*,*Abcdij*, Abcdklmnop*, Aabcd*
    The found text should start with "abcd" (case insensitive), after "abcd" it should have 1 or more characters which start with blank, "-", "_", or some other special character, but should not start with a letter!
    Is it possible to achieve it with oracle text index?
    Regards

    You must define the hypen etc. as SKIPJOINS not as PRINTJOINS.
    BTW your create index skript fails due to wrong parameter name.
    BEGIN
      CTX_DDL.CREATE_PREFERENCE('SUBSTR_PREF','BASIC_WORDLIST');
      CTX_DDL.SET_ATTRIBUTE('SUBSTR_PREF','SUBSTRING_INDEX','TRUE');
      CTX_DDL.CREATE_PREFERENCE('pj_lex', 'BASIC_LEXER');
      CTX_DDL.SET_ATTRIBUTE('pj_lex', 'SKIPJOINS', '-');
    END;
    CREATE INDEX IDX_T1_STR ON T1
    (STR)
    INDEXTYPE IS CTXSYS.CONTEXT
    PARAMETERS('wordlist  SUBSTR_PREF
                LEXER     pj_lex'
    select *
    from t1
    where
    contains (str, 'abcd') > 0
    STR
    Abcd ef
    Abcd
    abcd
    Abcd - ef
    Abcd - 12
    Abcd_ef12 Edited by: chris227 on 06.03.2013 00:58
    Example added

  • Error synchronizing text index in oracle 10g

    Hi,
    I am getting errors while trying to synchronize the text index on a xmltype table.
    SQL> exec ctx_ddl.sync_index('CTX_INDEX');
    BEGIN ctx_ddl.sync_index('CTX_INDEX'); END;
    ERROR at line 1:
    ORA-20000: Oracle Text error:
    DRG-50857: oracle error in drsxsopen
    ORA-00904: "BASE"."SYS_NC00162$"."GETCLOBVAL": invalid identifier
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.CTX_DDL", line 539
    ORA-06512: at line 1
    I will appreciate it if someone can help me figure out a solution.
    (Oracle database version - 10.2.0.1)
    Thanks,
    Uma

    Testing with 10.2.0.2.0 I do not see the problem. Is there something significanly different between your environement and the one in this testcase
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue Feb 28 16:16:54 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool createTextIndex.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> desc ENTRY_TABLE
    Name                                      Null?    Type
    TABLE of SYS.XMLTYPE(XMLSchema "http://www.uniprot.org/support/docs/uniprot.xsd" Element "entry") STORAGE Object-relational TYPE "ENTRY_T"
    SQL> /
    SP2-0103: Nothing in SQL buffer to run.
    SQL> create index UNIPROT_FULL_TEXT
      2      on ENTRY_TABLE e (object_value)
      3         indextype is ctxsys.context
      4         parameters ( 'section group ctxsys.NULL_SECTION_GROUP' )
      5  /
    Index created.
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue Feb 28 16:16:58 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool loadFile_&3..log
    SQL> set trimspool on
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> set timing on
    SQL> --
    SQL> declare
      2    result boolean;
      3  begin
      4    result := dbms_xdb.createResource('/home/&1/&3',
      5                                      bfilename(USER,'&3'),nls_charset_id('AL32UTF8'));
      6  end;
      7  /
    old   4:   result := dbms_xdb.createResource('/home/&1/&3',
    new   4:   result := dbms_xdb.createResource('/home/BASE/testcase.xml',
    old   5:                                     bfilename(USER,'&3'),nls_charset_id('AL32UTF8'));
    new   5:                                     bfilename(USER,'testcase.xml'),nls_charset_id('AL32UTF8'));
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.70
    SQL> commit
      2  /
    Commit complete.
    Elapsed: 00:00:00.08
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue Feb 28 16:16:59 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool testcase.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> --
    SQL> -- Testcase code here
    SQL> --
    SQL> set trimspool on
    SQL> set autotrace on explain
    SQL> set timing on
    SQL> set pages 0 lines 140 long 100000
    SQL> --
    SQL> select count(*)
      2    from ENTRY_TABLE
      3  /
             1
    Elapsed: 00:00:00.21
    Execution Plan
    Plan hash value: 4248071425
    | Id  | Operation          | Name        | Rows  | Bytes | Cost (%CPU)| Time    |
    |   0 | SELECT STATEMENT   |             |     1 |    20 |     3   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE    |             |     1 |    20 |            |         |
    |*  2 |   TABLE ACCESS FULL| ENTRY_TABLE |     1 |    20 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
                  xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
                  http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xs
                  d"><read-properties/><read-contents/></privilege>'))=1)
    Note
       - dynamic sampling used for this statement
    SQL> select object_value
      2    from ENTRY_TABLE
      3   where existsNode (OBJECT_value, '/entry[accession/text()="P19084"]','xmlns="http://uniprot.org/uniprot"')>0
      4  /
    *** Object defn.s out of sync w/ data
    ***<entry xmlns="http://uniprot.org/uniprot" dataset="Swiss-Prot" created="1990-11-01" modified="2006-02-07" version="45">
      <accession>P19084</accession>
      <name>11S3_HELAN</name>
    PLTLWANRYQLSREEAQQLKFSQRETVLFAPSFSRGQGIRASR
    </sequence>
    </entry>
    Elapsed: 00:00:03.13
    Execution Plan
    Plan hash value: 4171466134
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                |     1 | 10115 |   804  (1)| 00:00:10 |
    |   1 |  NESTED LOOPS                |                |     1 | 10115 |   804  (1)| 00:00:10 |
    |   2 |   SORT UNIQUE                |                |     1 |  2016 |   802  (0)| 00:00:10 |
    |*  3 |    INDEX FAST FULL SCAN      | ACCESSION_DATA |     1 |  2016 |   802  (0)| 00:00:10 |
    |*  4 |   TABLE ACCESS BY INDEX ROWID| ENTRY_TABLE    |     1 |  8099 |     1  (0)| 00:00:01 |
    |*  5 |    INDEX UNIQUE SCAN         | ACCESSION_LIST |     1 |       |     0  (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("ACCESSION_TABLE"."SYS_XDBBODY$"='P19084')
       4 - filter(SYS_CHECKACL("ACLOID","OWNERID",xmltype('<privilege
                  xmlns="http://xmlns.oracle.com/xdb/acl.xsd"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd
                  http://xmlns.oracle.com/xdb/acl.xsd DAV:http://xmlns.oracle.com/xdb/dav.xsd"><read-prop
                  erties/><read-contents/></privilege>'))=1)
       5 - access("NESTED_TABLE_ID"="ENTRY_TABLE"."SYS_NC0001100012$")
    Note
       - dynamic sampling used for this statement
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL*Plus: Release 10.2.0.2.0 - Production on Tue Feb 28 16:17:03 2006
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    SQL> spool syncTextIndex.log
    SQL> --
    SQL> connect &1/&2
    Connected.
    SQL> --
    SQL> exec ctx_ddl.sync_index('UNIPROT_FULL_TEXT')
    PL/SQL procedure successfully completed.
    SQL> /
    SP2-0103: Nothing in SQL buffer to run.
    SQL> quit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    bash-2.05b$Message was edited by:
    mdrake

  • End-of-file on communicaton channel when creating text index on xmltype tab

    Hi,
    I'm trying to create an oracle text index on a table of xmltype. This table is using an xml schema and the table is using object relational storage.
    I have another table that is a relational table that has an xml type column, and I was able to create the text index on that xmltype column without any problems.
    Here's the create index statement and the error:
    1 create index table_one_text_index
    2 on table_one(object_value)
    3 indextype is ctxsys.context
    4 parameters
    5* ('section group ctxsys.path_section_group')
    6 /
    create index table_one_text_index
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Process ID: 27137
    Session ID: 65 Serial number: 24961
    Any ideas? I've looked through the oracle text and the oracle xml db documentation and the forums and haven't found any ideas about what's causing the problem or how to fix it.
    Thank you

    Is the data in the XMLType columns the same in both cases.. Can you provide a testcase ? Which DB release are you working with

  • End-of-file on communicaton channel when creating text index on xmltype ta

    Hi,
    I'm trying to create an oracle text index on a table of xmltype. This table is using an xml schema and the table is using object relational storage.
    I have another table that is a relational table that has an xml type column, and I was able to create the text index on that xmltype column without any problems.
    Here's the create index statement and the error:
    1 create index table_one_text_index
    2 on table_one(object_value)
    3 indextype is ctxsys.context
    4 parameters
    5* ('section group ctxsys.path_section_group')
    6 /
    create index table_one_text_index
    ERROR at line 1:
    ORA-03113: end-of-file on communication channel
    Process ID: 27137
    Session ID: 65 Serial number: 24961
    Any ideas? I've looked through the oracle text and the oracle xml db documentation and the forums and haven't found any ideas about what's causing the problem or how to fix it.
    Thank you

    A 3113 error indicates the Oracle background process has crashed. This almost always indicates a bug. Suggest you take a look at your database alert log file, and report this to Oracle Support.

  • Problem with oracle text indexes during import

    We have a 9.2.0.6 database using oracle text features on a server with windows 2000 5.00.2195 SP4.
    We need to export its data ( user ARIANE only ) and then import the result into another 9.2.0.6 database.
    The import never comes to an end.
    The only way to make it work is to use the "indexes=n" clause.
    Then ( without the indexes ), we tried to create manually the oracle text indexes.
    We get this error :
    CREATE INDEX ARIANE.DOSTEXTE_DTTEXTE_CTXIDX ON ARIANE.DOSTEXTE (DTTEXTE)
    INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS('lexer ariane_lexer stoplist ctxsys.default_stoplist storage ariane_storage');
    ORA-29855: erreur d'exécution de la routine ODCIINDEXCREATE
    ORA-20000: Erreur Oracle Text :
    DRG-10700: préférence inexistante : ariane_lexer
    ORA-06512: à "CTXSYS.DRUE", ligne 157
    ORA-06512: à "CTXSYS.TEXTINDEXMETHODS", ligne 219
    We then tried to uninstall Oracle text and install it ( My Oracle Support [ID 275689.1] ). The index creation above still fails.
    We also checked our Text installation and setup through My Oracle Support FAQ ( ID 153264.1 ) and everything seems ok.
    Do we have to create some ARIANE* lexer preferences through specific pl/sql ( ctx_report* ? ) before importing anything from the ARIANE user ?
    What do we need to do exactly when exporting data with oracle text features from one database to another given we used to restore the database through a copy of the entire windows files ?
    Is there a specific order to follow to succeed an import ?
    Thank you for your help.
    Jean-michel, Nemours, FRANCE

    Hi
    index preferences are not exported, ie ariane_lexer + ariane_storage, only the Text index metada, thus the DRG-10700 from index DDL on target/import DB.
    I recommend to use ctx_report.create_index_script on source/export DB, see Doc ID 189819.1 for details, export with indexes=N and then create text indexes manually after data import.
    -Edwin

  • SMB Server using Oracle Text  Index

    Hi folks,
    I am looking into IFS and can't find any info
    on whether IFS is able to use the Oracle Text
    indexing, when accessed through SMB (directory mount).
    If I search for a file containing a given string
    is that search executed within IFS and only the
    resultset returned to the client, or is every
    file read from IFS delivered to the client,
    searched there and then thrown away if it doesn't
    contain the string (rendering the Text Index useless)?
    Does anybody have background info / experience with this?
    Regards
    Jan-Peter

    Hi folks,
    I am looking into IFS and can't find any info
    on whether IFS is able to use the Oracle Text
    indexing, when accessed through SMB (directory mount).
    If I search for a file containing a given string
    is that search executed within IFS and only the
    resultset returned to the client, or is every
    file read from IFS delivered to the client,
    searched there and then thrown away if it doesn't
    contain the string (rendering the Text Index useless)?
    Does anybody have background info / experience with this?
    Regards
    Jan-Peter To answer your question, it would help to have a little more context (pardon the pun). Are you trying to (1) understand how the 9iFS Windows UI uses Oracle Text, or (2) are you trying to write a client application that somehow uses the Text index on 9iFS content?

  • Create Oracle Text Index from Java via JDBC

    Hi, I have a question relevant to creation of the Text Index in Oracle Text via Java JDBC.
    In Java I create client application and I connect to remote Oracle server. (there is Oracle
    10g Enterprise Edition 10.2.0.3.0 on Debian Linux OS). In Java I create query:
    CREATE INDEX index_name ON source_tab(text) indextype is ctxsys.context
    parameters('datastore ctxsys.file_datastore filter ctxsys.null_filter');
    and I start it by:
    PreparedStatement stmt = db.prepareStatement(query);
    ResultSet rs = stmt.executeQuery();
    There is problem that Text Index is created empty and when I write out error log then:
    DRG-11513: unable to open or write to file "path"
    I have on my computer Oracle XE 10g (Windows XP OS) here this application in Java functions
    without problems. Without problems it´s with that same query in SQLPlus when I connect at
    this remote Oracle server via PuTTY.
    Do you know anybody where could be error? Or at worst case where find I more detailed
    manual about JDBC Oracle mainly possible errors and problems with compatibility?

    Does it work if you don't use "file_datastore"?
    Eg. try the following in sqlplus:
    create table t (text varchar2(2000));
    insert into t values ('hello world');
    create index ti on t(text) indextype is ctxsys.context;
    select * from t where contains (text, 'hello') > 0;
    Then drop the index ti and try the same "create index" through JDBC. Does that work?
    If so, then we have some kind of issue with the file_datastore. I assume you are aware that the file will be read by the SERVER, not from the client?
    So if your database resides on a Linux box, but you are calling from a Java program on a windows PC, the file names in source_tab(text) must be in Linux format, and must refer to files which are available on the Linux server (and readable by the owner of the Oracle database process).
    So /home/me/file.txt might work, but C:\Documents\file.txt will not.

  • Text index for UNION queries.

    Hi All,
    Can anyone please help me in tuning search query mentioned below
    select id from usr1.organizations where lower(ID_official_name)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.organizations where lower(ID_OFFICIAL_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_ALIAS_NAMEs where lower(ID_ALIAS_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_dba_name)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_DOING_BUSINESS_AS_NAMES where lower(ID_DBA_TRANS_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fka_name)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_ENG_NORM_NAME)   like  'technology%'
    union
    select id from usr1.ID_FKA_NAMES where lower(ID_fkA_TRANS_NAME)   like  'technology%'Here organizations table is the parent table having primary key on id column, and rest all tables are children tables having foreign key on id column referencing to primary key id column in organizations table.
    Planning to implement multiple column(Userdatastore) text index on dummy column appended to organizations table. And write triggers on other child tables to trigger the sync for Text index.
    But not sure whether we can rewrite this above sql query by replacing union into joins, not sure why developer has not done so.
    Can anyone please help me in creating text index for this sql. I do not want to approach cartesian joins as these are having parent-child relationship.
    Oracle Version: 10.2.0.4
    Please let me know if you need more information

    1 .As text index is created in parent table on id column, can we somehow search only from particular columns(Parent or child) by using user_datastore and tags for sectioning it?
    Below are the sql which i need to make use of text index
    select m.id from id_ALIAS_NAMEs an
    join organizations m on(m.id=an.id)
    where lower(ID_ALIAS_NAME)   like  'technology%' and m.id_data_provider<100;
    select M.id,ID_ALIAS_NAME,'ID_ALIAS_NAME' AS NAMETYPE
    from id_alias_names an JOIN organizations m ON m.id=an.id
    where id_data_provider<100 AND coalesce(m.ID_COUNTRY_OF_DOMICILE,m.ID_COUNTRY_OF_INCORPORATION)='US'
    AND LOWER(ID_ALIAS_NAME) like LOWER('TECHNOLOGY%')
    and F_GetFirstWord(ORG_ALIAS_NAME)='TECHNOLOGY'
    The text index must be created on a text column, not a numeric id column. It is common to create it on a dummy column. You can name that column anything you like instead of dummy, like search_columns or some such thing. You can add tags in your procedure, so that your resulting virtual column is like xml data. You can then create a section group, so that you can search within each of those tags. In the example below, I used ctxsys.auto_section_group because it is the simplest to create, but you may get better performance by using another type of section group and naming each individual tag.
    SCOTT@orcl_11gR2> -- tables you already have:
    SCOTT@orcl_11gR2> create table organizations
      2    (id                    number primary key,
      3       id_official_name          varchar2 (10),
      4       id_official_norm_name          varchar2 (10),
      5       id_official_eng_name          varchar2 (10),
      6       id_official_trans_name          varchar2 (10),
      7       id_data_provider          number,
      8       id_country_of_domicile          varchar2 (10),
      9       id_country_of_incorporation  varchar2 (10))
    10  /
    Table created.
    SCOTT@orcl_11gR2> create table id_alias_names
      2    (id                    number references organizations (id),
      3       id_alias_name               varchar2 (10),
      4       id_alias_norm_name          varchar2 (10),
      5       id_alias_eng_name          varchar2 (10),
      6       id_alias_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_doing_business_as_names
      2    (id                    number references organizations (id),
      3       id_dba_name               varchar2 (10),
      4       id_dba_norm_name          varchar2 (10),
      5       id_dba_eng_name           varchar2 (10),
      6       id_dba_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> create table id_fka_names
      2    (id                    number references organizations (id),
      3       id_fka_name               varchar2 (10),
      4       id_fka_norm_name          varchar2 (10),
      5       id_fka_eng_name           varchar2 (10),
      6       id_fka_trans_name          varchar2 (10))
      7  /
    Table created.
    SCOTT@orcl_11gR2> -- test data:
    SCOTT@orcl_11gR2> insert all
      2  into organizations values (1, 'test', 'name2', 'name3', 'name4', 99, 'US', null)
      3  into organizations values (2, 'name1', 'name2', 'name3', 'name4', 99, null, 'US')
      4  into organizations values (3, 'name1', 'name2', 'name3', 'name4', 99, null, null)
      5  into organizations values (4, 'name1', 'name2', 'name3', 'name4', 101, 'US', 'US')
      6  into organizations values (5, 'technology', 'technology', 'technology', 'technology', 99, 'US', 'US')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_alias_names values (1, 'technology', 'name6', 'name7', 'name8')
      3  into id_alias_names values (2, 'technology', 'test', 'name7', 'name8')
      4  into id_alias_names values (3, 'technology', 'name6', 'name7', 'name8')
      5  into id_alias_names values (4, 'technology', 'name6', 'name7', 'name8')
      6  into id_alias_names values (5, 'name5', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_doing_business_as_names values (1, 'name9', 'name10', 'name11', 'name12')
      3  into id_doing_business_as_names values (2, 'name9', 'name10', 'name11', 'name12')
      4  into id_doing_business_as_names values (3, 'name9', 'name10', 'test', 'name12')
      5  into id_doing_business_as_names values (4, 'name9', 'name10', 'name11', 'name12')
      6  into id_doing_business_as_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> insert all
      2  into id_fka_names values (1, 'name13', 'name14', 'name15', 'name16')
      3  into id_fka_names values (2, 'name13', 'name14', 'name15', 'name16')
      4  into id_fka_names values (3, 'name13', 'name14', 'name15', 'name16')
      5  into id_fka_names values (4, 'name13', 'name14', 'name15', 'test')
      6  into id_fka_names values (5, 'technology', 'technology', 'technology', 'technology')
      7  select * from dual
      8  /
    5 rows created.
    SCOTT@orcl_11gR2> -- revised procedure to join tables with tags:
    SCOTT@orcl_11gR2> create or replace procedure your_proc
      2    (p_rowid in           rowid,
      3       p_clob     in out nocopy clob)
      4  as
      5  begin
      6    for r1 in
      7        (select id,
      8             '<id_official_name>'
      9             || id_official_name
    10             || '</id_official_name><id_official_norm_name>'
    11             || id_official_norm_name
    12             || '</id_official_norm_name><id_official_eng_name>'
    13             || id_official_eng_name
    14             || '</id_official_eng_name><id_official_trans_name>'
    15             || id_official_trans_name
    16             || '</id_official_trans_name>' as tags_and_values
    17         from      organizations
    18         where  rowid = p_rowid)
    19    loop
    20        dbms_lob.writeappend
    21          (p_clob, length (r1.tags_and_values), r1.tags_and_values);
    22        for r2 in
    23          (select '<id_alias_name>'
    24               || id_alias_name
    25               || '</id_alias_name><id_alias_norm_name>'
    26               || id_alias_norm_name
    27               || '</id_alias_norm_name><id_alias_eng_name>'
    28               || id_alias_eng_name
    29               || '</id_alias_eng_name><id_alias_trans_name>'
    30               || id_alias_trans_name
    31               || '</id_alias_trans_name>' as tags_and_values
    32           from   id_alias_names
    33           where  id = r1.id)
    34        loop
    35          dbms_lob.writeappend
    36            (p_clob, length (r2.tags_and_values), r2.tags_and_values);
    37        end loop;
    38        for r3 in
    39          (select '<id_dba_name>'
    40               || id_dba_name
    41               || '</id_dba_name><id_dba_norm_name>'
    42               || id_dba_norm_name
    43               || '</id_dba_norm_name><id_dba_eng_name>'
    44               || id_dba_eng_name
    45               || '</id_dba_eng_name><id_dba_trans_name>'
    46               || id_dba_trans_name
    47               || '</id_dba_trans_name>' as tags_and_values
    48           from   id_doing_business_as_names
    49           where  id = r1.id)
    50        loop
    51          dbms_lob.writeappend
    52            (p_clob, length (r3.tags_and_values), r3.tags_and_values);
    53        end loop;
    54        for r4 in
    55          (select '<id_fka_name>'
    56               || id_fka_name
    57               || '</id_fka_name><id_fka_norm_name>'
    58               || id_fka_norm_name
    59               || '</id_fka_norm_name><id_fka_eng_name>'
    60               || id_fka_eng_name
    61               || '</id_fka_eng_name><id_fka_trans_name>'
    62               || id_fka_trans_name
    63               || '</id_fka_trans_name>' as tags_and_values
    64           from   id_fka_names
    65           where  id = r1.id)
    66        loop
    67          dbms_lob.writeappend
    68            (p_clob, length (r4.tags_and_values), r4.tags_and_values);
    69        end loop;
    70    end loop;
    71  end your_proc;
    72  /
    Procedure created.
    SCOTT@orcl_11gR2> show errors
    No errors.
    SCOTT@orcl_11gR2> -- examples of virtual columns that revised procedure returns:
    SCOTT@orcl_11gR2> declare
      2    v_clob  clob;
      3  begin
      4    for r in
      5        (select rowid, id
      6         from      organizations)
      7    loop
      8        dbms_lob.createtemporary (v_clob, true);
      9        your_proc (r.rowid, v_clob);
    10        dbms_output.put_line (r.id);
    11        dbms_output.put_line (v_clob);
    12        dbms_lob.freetemporary (v_clob);
    13    end loop;
    14  end;
    15  /
    1
    <id_official_name>test</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name3
    </id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><i
    d_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    2
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>test</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_a
    lias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_d
    ba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_f
    ka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    3
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>test</id_db
    a_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_fk
    a_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>name16</id_fka_trans_name>
    4
    <id_official_name>name1</id_official_name><id_official_norm_name>name2</id_official_norm_name><id_official_eng_name>name
    3</id_official_eng_name><id_official_trans_name>name4</id_official_trans_name><id_alias_name>technology</id_alias_name><
    id_alias_norm_name>name6</id_alias_norm_name><id_alias_eng_name>name7</id_alias_eng_name><id_alias_trans_name>name8</id_
    alias_trans_name><id_dba_name>name9</id_dba_name><id_dba_norm_name>name10</id_dba_norm_name><id_dba_eng_name>name11</id_
    dba_eng_name><id_dba_trans_name>name12</id_dba_trans_name><id_fka_name>name13</id_fka_name><id_fka_norm_name>name14</id_
    fka_norm_name><id_fka_eng_name>name15</id_fka_eng_name><id_fka_trans_name>test</id_fka_trans_name>
    5
    <id_official_name>technology</id_official_name><id_official_norm_name>technology</id_official_norm_name><id_official_eng
    _name>technology</id_official_eng_name><id_official_trans_name>technology</id_official_trans_name><id_alias_name>name5</
    id_alias_name><id_alias_norm_name>technology</id_alias_norm_name><id_alias_eng_name>technology</id_alias_eng_name><id_al
    ias_trans_name>technology</id_alias_trans_name><id_dba_name>technology</id_dba_name><id_dba_norm_name>technology</id_dba
    _norm_name><id_dba_eng_name>technology</id_dba_eng_name><id_dba_trans_name>technology</id_dba_trans_name><id_fka_name>te
    chnology</id_fka_name><id_fka_norm_name>technology</id_fka_norm_name><id_fka_eng_name>technology</id_fka_eng_name><id_fk
    a_trans_name>technology</id_fka_trans_name>
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- user_datastore:
    SCOTT@orcl_11gR2> begin
      2    ctx_ddl.create_preference ('your_datastore', 'user_datastore');
      3    ctx_ddl.set_attribute ('your_datastore', 'procedure', 'your_proc');
      4  end;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> -- dummy column:
    SCOTT@orcl_11gR2> alter table organizations add (dummy varchar2(1))
      2  /
    Table altered.
    SCOTT@orcl_11gR2> -- index with auto_section_group,
    SCOTT@orcl_11gR2> -- must be on a text column, like dummy, not numeric id column:
    SCOTT@orcl_11gR2> create index your_index
      2  on organizations (dummy)
      3  indextype is ctxsys.context
      4  parameters
      5    ('datastore     your_datastore
      6        section group     ctxsys.auto_section_group')
      7  /
    Index created.
    SCOTT@orcl_11gR2> -- example queries:
    SCOTT@orcl_11gR2> select id
      2  from   organizations
      3  where  contains (dummy, 'technology within id_alias_name') > 0
      4  and    id_data_provider < 100
      5  /
            ID
             1
             2
             3
    3 rows selected.
    SCOTT@orcl_11gR2> select m.id, an.id_alias_name, 'ID_ALIAS_NAME' as nametype
      2  from   id_alias_names an join organizations m on m.id = an.id
      3  where  contains (m.dummy, 'technology within id_alias_name') > 0
      4  and    m.id_data_provider < 100
      5  and    coalesce (m.id_country_of_domicile, m.id_country_of_incorporation) = 'US'
      6  /
            ID ID_ALIAS_N NAMETYPE
             1 technology ID_ALIAS_NAME
             2 technology ID_ALIAS_NAME
    2 rows selected.
    SCOTT@orcl_11gR2>

  • Oracle Text Indexing performance in Unicode database

    Forum folks,
    I'm looking for overall performance thoughts in Text Indexing within a Unicode database. Part of our internal testing suites includes searching on values using contains filters over indexed binary and text documents. We've architected these tests such that they could be run in a suite or on their own, thus, the data is loaded at the beginning of each test and then the text indexes are created and populated prior to running any of the actual testing.
    We have the same tests running on non-unicode instances of Oracle 11gR2 just fine, but when we run them against a Unicode instance, we are almost always seeing timing issues where the indexes haven't finished populating, thus our tests are saying we've only found n number of hits when we are expecting n+ 50 or in some cases n + 150 records to be returned.
    We are just looking for some general information in regards to text indexing performance in a unicode database. Will we need to add sleep time to the testing to allow for the indexes to populate? How much time? We would rather not get into having to create different tests for unicode vs non-unicode, but perhaps that is necessary.
    Any insight you could provide would be most appreciated.
    Thanks in advance,
    Dan

    Roger,
    Thanks much for your quick reply...
    When you talk about Unicode, do you mean AL32UTF8?
    --> Yes, this is the Unicode charset we are using.
    Is the data the same in both cases, or are you indexing simple 7-bit ascii data in the one database, and foreign text (maybe Chinese?) in the UTF8 database?
    With the same data, there should be virtually no difference in performance due to the AL32UTF8 database character set.
    --> We have a data generation tool we utilize. For non-unicode data, we generate using all 256 characters in the ISO-8859-1 set. With our Unicode data for clobs, we generate using only the first 1,000 characters of UTF8 by setting up an array of code points...0 - 1000. For Blobs, we have sets of sample word documents and pdfs that are inserted, then indexed.
    I'm not sure I understand your testing methodology. Do you run ( load-data, index-data, run-queries ) sequentially?
    --> That is correct. We utilize the ctx_ddl package to populate the pending table and then to sync the index....The following is an example of the ddl we generate to create and populate the index:
    create index "DBMEARSPARK_ORA80"."RESRESUMEDOC" on "DBMEARSPARK_ORA80"."RESUME" ("RESUMEDOC") indextype is CTXSYS.CONTEXT parameters(' nopopulate sync (every "SYSTIMESTAMP + INTERVAL ''30'' MINUTE" PARALLEL 2) filter ctxsys.auto_filter ') PARALLEL 2;
    execute ctx_ddl.populate_pending('"DBMEARSPARK_ORA80"."RESRESUMEDOC"',null);
    execute ctx_ddl.sync_index('"DBMEARSPARK_ORA80"."RESRESUMEDOC"',null,null,2);
    If so, there should be no way that the indexes can be half-created. If not, don't you have some check to see if the index creation has finished before running the query test?
    --> Excellent question....is there such a check? I have not found a way to do that yet...
    Were you just lucky with the "non-unicode" tests that the indexing just happened to have always finished by the time you ran the queries?
    --> This is quite possible as well. If there is a check to see if the index is ready, then we could add that into our infrastructure.
    --> Thanks, again, for responding so quickly.
    Edited by: djulson on Feb 12, 2013 7:13 AM

  • PMPoint to Text Index conversion

    Hi All,
    Can anyone guide me for the following,
    - I am having a PMPoint object in Pasteboard coordinate space and this lies within in a text box.
    - I want to calculate corresponding text index to this PMPoint.
    I didn't find any APIs in InDesign which takes a PMPoint and provide its corresponding text index in a text frame even in waxline and waxrun interfaces.
    Some Info:
    1) Application: Adobe InDesign CS4
    2) Machine:  MAC OS X
    Thanks,
    Vinod

    Many Thanks Dirk,
    I had manipulated this on the basis of wax line and wax run concept and calculated the text index, but now I think API suggested by you is better.
    Basically, I have one more problem related to this as follows,
    I have to make a continuous tracking of mouse movement, when it is within a text frame(during drop operation) and this tracking has to display with the help of a caret movement. So, After converting the PMPoint to Text index I am using
    Utils<IDragDropTextUtils>()->DrawCaretAtDropLocation(iLayoutview, storyRef, range) API.
    This way, I am able to draw a caret at the calculated text index.
    This API is working fine but the impression of old Caret still remains in the frame while mouse movement so lots of caret seems in the frame.
    So Can you please suggest me any methods to remove those old impression or any other API which can perform the caret movement at the specified index or any other way of doing the same.
    Some info:
    1) I am implementing this in a function DoDragWithin(IDragDropTarget* target, const PMPoint& localPt) of my class derived from CDragDropTargetFlavorHelper. Here I am getting a continuous call and also the updated PMPoint. So I think this is the function where I can show the mouse tracking with the help of a caret movement.
    2) All is related to Drag and Drop functionality.
    3) I see InDesign has this mouse tracking behavior when we drag text from another application and drop it on a text box (a cursor tracks the drop location)
    Tried so far:
    Tried below methods in DoDragWithin() to remove the old caret impression but no results,
    ITextParcelListComposer::RecomposeThruTextIndex()
    IFrameListComposer::RecomposeThru()
    Hope to get some help from you ASAP.
    Thanks,
    Vinod

  • Text index getting dropped on SET NULL?

    I am using Oracle 11g2 XE. With the following text index settings:
    ctx_ddl.create_preference('wrld_lexer', 'WORLD_LEXER');
    ctx_ddl.create_preference('TextIDX_preference', 'MULTI_COLUMN_DATASTORE');
    ctx_ddl.set_attribute('TextIDX_preference', 'columns', '"dummy", "FieldVarChar2", "FieldCLOB"');
    ctx_ddl.create_preference('wrdlist', 'BASIC_WORDLIST');
    ctx_ddl.set_attribute('wrdlist','PREFIX_INDEX','TRUE');
    ctx_ddl.set_attribute('wrdlist','PREFIX_MIN_LENGTH', '1');
    ctx_ddl.set_attribute('wrdlist','PREFIX_MAX_LENGTH', '15');
    ctx_ddl.set_attribute('wrdlist','SUBSTRING_INDEX', 'YES');
    ctx_ddl.set_attribute('wrdlist','WILDCARD_MAXTERMS', 5000) ;
    ctx_ddl.create_stoplist('universal_stoplist','BASIC_STOPLIST');
    CREATE INDEX TextIDX ON "TextTable"("dummy")
        INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS
         ('DATASTORE ME.TextIDX_preference LEXER ME.wrld_lexer WORDLIST ME.wrdlist STOPLIST ME.universal_stoplist FILTER CTXSYS.AUTO_FILTER SYNC (ON COMMIT)');The "FieldCLOB" is a nullable CLOB field is quite volatile. I have a task scheduled in Oracle to execute a stored procedure that first sets the whole column to NULL and afterwards inserts a bunch of text, ranging from a couple of words to over 4000 characters. It seems that whenever that stored procedure is called, afterwards my search engine can't find a thing! When I drop and create the index, it works again.. to a degree. It seems that the text index doesn't want to search on the FieldCLOB. It ignores it.
    Why is that so?
    I should note that I am fairly new to Oracle and I don't really know where to begin on this problem.

    I knew I've forgotten to add something to the question.
    The thing is that I am aware of that and I do have the trigger defined:
    create or replace
    trigger Text_trigger
    before update on "TextTable"
    for each row
    begin
      :new."dummy" := :new."dummy";
    end;This has worked in the past, but it seems that the changes I've made to the scheduled procedure drops the whole index or something. Here is my sproc:
    UPDATE "TextTable"
    SET "FieldCLOB" = NULL;
    commit;
    FOR pair IN (select "Find", "Append" from "Table1")
    LOOP          
      update "TextTable"
      set "FieldCLOB" = "FieldCLOB" || pair."Append"
      where ID in
         (select ID from "TextTable"
         where contains("dummy", pair."Find") > 0);
      commit;
    END LOOP;
    -- The problems started when I added this to the scheduled procedure:
    FOR pair IN (select "Find", "Append" from "Table2")
    LOOP          
      update "TextTable"
      set "FieldCLOB" = "FieldCLOB" || pair."Append"
      where ID in
         (select ID from "TextTable"
         where contains("dummy", pair."Find") > 0);
      commit;
    END LOOP;Edited by: 981243 on Mar 8, 2013 2:20 AM

  • Extracting stem words from text index

    Hello all,
    I am trying to categorize some records in a table. I wonder if Oracle Text has some searching capabilities inside the text index. So, what I'm trying to achieve is to find the minimum amount of stem words that can be found in a set of records. Basically, it's kind of reverse searching, I have a subset of records from a table that can be found using a regular query (no text query) - the table has a text index on one column - and I want to find, using the text index, the minimum amount of stem words in that column that can generate a hit for the whole subset if queried using only the text query.
    Thanks,
    Danny

    Here is a method for viewing the stem word of any given word by using a function that inserts one row into a table, dynamically rebuilds the index, then selects the stem word from the domain index table. I have then added some code to use that to loop through all the words in the original domain index table, insert them and their roots into another table, and select the roots and corresponding concatenated words.
    SCOTT@orcl_11gR2> SELECT banner FROM v$version
      2  /
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE     11.2.0.1.0     Production
    TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    5 rows selected.
    SCOTT@orcl_11gR2> CREATE TABLE test_tab (test_col VARCHAR2 (40))
      2  /
    Table created.
    SCOTT@orcl_11gR2> INSERT ALL
      2  INTO test_tab VALUES ('The cats ran quickly from the dogs.')
      3  INTO test_tab VALUES ('The mice were running from the cats.')
      4  INTO test_tab VALUES ('Some people walk their dogs every day.')
      5  INTO test_tab VALUES ('The dogs chased the cats.')
      6  SELECT * FROM DUAL
      7  /
    4 rows created.
    SCOTT@orcl_11gR2> BEGIN
      2    CTX_DDL.CREATE_PREFERENCE ('test_lex', 'AUTO_LEXER');
      3    CTX_DDL.SET_ATTRIBUTE ('test_lex', 'INDEX_STEMS', 'YES');
      4  END;
      5  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> CREATE INDEX test_idx ON test_tab (test_col)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  PARAMETERS
      4    ('LEXER       test_lex
      5        STOPLIST CTXSYS.EMPTY_STOPLIST')
      6  /
    Index created.
    SCOTT@orcl_11gR2> CREATE TABLE stem_tab
      2    (test_word  VARCHAR2 (4000))
      3  /
    Table created.
    SCOTT@orcl_11gR2> CREATE INDEX stem_idx on stem_tab (test_word)
      2  INDEXTYPE IS CTXSYS.CONTEXT
      3  PARAMETERS
      4    ('LEXER        stem_lex
      5        STOPLIST  CTXSYS.EMPTY_STOPLIST')
      6  /
    Index created.
    SCOTT@orcl_11gR2> CREATE OR REPLACE FUNCTION get_stem
      2    (p_word IN VARCHAR2)
      3    RETURN VARCHAR2
      4  AS
      5    v_word       VARCHAR2 (32767);
      6  BEGIN
      7    DELETE FROM stem_tab;
      8    COMMIT;
      9    INSERT INTO stem_tab (test_word) VALUES (p_word);
    10    COMMIT;
    11    EXECUTE IMMEDIATE 'ALTER INDEX stem_idx REBUILD';
    12    SELECT MIN (token_text)
    13    INTO   v_word
    14    FROM   dr$stem_idx$i;
    15    RETURN v_word;
    16  EXCEPTION
    17    WHEN NO_DATA_FOUND THEN RETURN p_word;
    18  END get_stem;
    19  /
    Function created.
    SCOTT@orcl_11gR2> SHOW ERRORS
    No errors.
    SCOTT@orcl_11gR2> CREATE TABLE words_and_stems
      2    (word  VARCHAR2 (20),
      3       stem  VARCHAR2 (20))
      4  /
    Table created.
    SCOTT@orcl_11gR2> SET SERVEROUTPUT ON
    SCOTT@orcl_11gR2> DECLARE
      2    v_stem VARCHAR2 (32767);
      3  BEGIN
      4    FOR r IN
      5        (SELECT DISTINCT token_text
      6         FROM      dr$test_idx$i
      7         WHERE  token_text != '.')
      8    LOOP
      9        v_stem := get_stem (r.token_text);
    10        INSERT INTO words_and_stems
    11        VALUES (r.token_text, v_stem);
    12    END LOOP;
    13    COMMIT;
    14  END;
    15  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11gR2> COLUMN words FORMAT A45 WORD_WRAPPED
    SCOTT@orcl_11gR2> SELECT stem,
      2           LISTAGG (word, ', ') WITHIN GROUP (ORDER BY word)
      3             AS words
      4  FROM   words_and_stems
      5  GROUP  BY stem
      6  /
    STEM                 WORDS
    BE                   BE, WERE
    CAT                  CAT, CATS
    CHASE                CHASE, CHASED
    DAY                  DAY
    DOG                  DOG, DOGS
    EVERY                EVERY
    FROM                 FROM
    MICE                 MICE
    MOUSE                MOUSE
    PEOPLE               PEOPLE
    QUICKLY              QUICKLY
    RAN                  RAN
    RUN                  RUN, RUNNING
    SOME                 SOME
    THE                  THE
    THEIR                THEIR
    WALK                 WALK
    17 rows selected.
    SCOTT@orcl_11gR2>

Maybe you are looking for