Highlighting results using oracle text
Hi
I've hooked up to Oracle text using odp.net and can query that fine. Now I would like to use the highlighting feature of OT but I'm having problems finding suitable examples of how to do it.
I've read through a number of Oracle Text documents, they say use CTX_DOC package to hightlight the result but that's PL/SQL. How can I do it with odp.net ?
thanks
Ok thanks for that - I've done that and its cleared the error but I'm still finding more problems
i've tweaked my code some more as the one and currently have this
setType();
OracleConnection oConn= dbConnect();
//setType();
oConn.Open();
OracleCommand oCmd = new OracleCommand();
oCmd.CommandText = "ctx_doc.Highlight";
oCmd.Connection = oConn;
oCmd.CommandType=CommandType.StoredProcedure;
//params
OracleParameter oparam2 = oCmd.Parameters.Add("index_name", OracleDbType.Varchar2);
oparam2.Direction = ParameterDirection.Input;
oparam2.Value = "description_idx";
OracleParameter oparam3 = oCmd.Parameters.Add("textkey", OracleDbType.Varchar2);
oparam3.Direction = ParameterDirection.Input;
oparam3.Value = "ID";
OracleParameter oparam4 = oCmd.Parameters.Add("text_query", OracleDbType.Varchar2);
oparam4.Direction = ParameterDirection.Input;
oparam4.Value = "test || hello";
OracleParameter oparam = oCmd.Parameters.Add("restab", OracleDbType.Varchar2);
oparam.Value = "ctx_hitab";
oparam.Direction = ParameterDirection.Input;
OracleParameter oparam5 = oCmd.Parameters.Add("plaintext", OracleDbType.Int32);
oparam5.Direction = ParameterDirection.Input;
oparam5.Value = false;
OracleDataAdapter da = new OracleDataAdapter(oCmd);
DataSet ds = new DataSet();
da.Fill(ds,"TEST");
//oCmd.ExecuteNonQuery();
oConn.Close();
and it's producing this error which obviously relates to parameter 3 but I'm not sure how I can correct it.
ORA-20000: Oracle Text error: DRG-11445: rowid value is invalid: ID ORA-06512:
at "CTXSYS.DRUE", line 157 ORA-06512: at "CTXSYS.CTX_DOC", line 876 ORA-06512: at
line 1
many thanks
Similar Messages
-
Strange result using Oracle Text
Hello, I am receiving a strange exception with this sql query
SELECT * FROM gob_attachment
WHERE CONTAINS (gob_a_document, 'java') > 0
It's giving me
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
ORA-00942: table or view does not exist
29902. 00000 - "error in executing ODCIIndexStart() routine"
*Cause: The execution of ODCIIndexStart routine caused an error.
*Action: Examine the error messages produced by the indextype code and
take appropriate action.
After some googling I've disovered that problem could be in index, but I looked at the table and index seems ok to me.
Create script for index is looking like this
CREATE INDEX FTSI_GOB_A_DOCUMENT ON GOB_ATTACHMENT (GOB_A_DOCUMENT) INDEXTYPE IS CTXSYS.CONTEXT;
Only thing which is strange to me is that when I look to Edit Table in Table properties in SQL Developer I can see that Operational Status of index is FAILED. Does anyone know what does it mean?Maybe DB rights?
Edited by: 918345 on 2.3.2012 1:40
Edited by: 918345 on 2.3.2012 1:44No, I don't see any message related to this matter in there. I also tried to recreate the index and now the query is working, but it's not returning any results.
So I did this
drop index blob_index
create index blob_index on docs_mixedmedia(doc_contents) indextype is ctxsys.context
I've also discovered that we are storing unsupported datatype(DOCX), because it's supported from version 11 and we are running on 10g, could this lead to empty result of queries? -
Using Oracle Text for searching with UCM 10g
I am using Oracle text with UCM 10gR3 and Site Studio 10gR4 and I am trying to sort the search results by relevancy and to also include a snippet of the retrieved document. I have the fields that the SS_GET_SEARCH_RESULTS service returns but the relevancy score is always equals 5 and the snippet contains characters such as < idcnull, /p, etc., which you can see are XML/HTML/UCM tags but which result sin even more strangeness in the snippet if I try to remove them programmatically.
I have read the Oracle Text documentation and there appear to be ways you can configure Oracle Text but I am not clear at all on what I can do from UCM. It looks like the configuration is either done in database tables or in the query itself, neither of which are readily configurable to me.
Is anyone experienced in this or know of any documentation this might help?
BillHi
If I remember correctly then this issue was seen with an older version of OTS component and Core Update patch / bundle . Upgrade the UCM instance with the latest CS10gr35 update bundle patchset 6907073 and also upgrade OTS component from the same patchset .
Let me know how it goes after this .
Thanks
Srinath -
Document management system using oracle text
i plan to create document management system using oracle text with following features
1) document comparision
2) document search
and more...
can oracle text be used to display documents of various formats by converting them to HTML. and can search keywords be highlighted in the document.
please help!Have you ever considered doing this in Oracle Application Express (free on top of the Oracle database)? How about something like:
http://download-west.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm
Index the files using the CONTEXT index, and perhaps the docs' meta with it using the Oracle Text MULTI_COLUMN_DATASTORE, and then when you write your query for a report on the documents include a search string.
I've created a number of APEX-based document management systems and it is quite easy once you get the hang of using this environment. I suggest looking at some of the tutorials/how-to documents and you'll be on your way quickly.
Start with the upload application. Once you can get your documents in, create a report that shows everything except the document. Verify all of this works correctly.
Add some "items" to the page for the report, and include them as bind variables in the where clause.
After that, add your Oracle Text index to the database, and toss in a "text-field" item to the APEX page. Modify your report query, adding the CONTAINS clause, and use the newly created item as a bind variable. There's your keyword search.
Linking to Oracle Apps is done through API's and may be over database links.
Hope it helps. Though not a step-by-step how to document, this should point you in the right direction. Get familiar with APEX as that covers most of what you described.
-Ron -
Problem with blob column index created using Oracle Text.
Hi,
I'm running Oracle Database 10g 10.2.0.1.0 standard edition one, on windows server 2003 R2 x64.
I have a table with a blob column which contains pdf document.
Then, I create an index using the following script so that I can do fulltext search using Oracle Text.
CREATE INDEX DMCS.T_DMCS_FILE_DF_FILE_IDX ON DMCS.T_DMCS_FILE
(DF_FILE)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS('DATASTORE CTXSYS.DEFAULT_DATASTORE');
However, the index is not searchable and I check the following tables created by database for my index and found them to be empty as well !!
DR$T_DMCS_FILE_DF_FILE_IDX$I
DR$T_DMCS_FILE_DF_FILE_IDX$K
DR$T_DMCS_FILE_DF_FILE_IDX$N
DR$T_DMCS_FILE_DF_FILE_IDX$R
I wonder what's wrong with it.
My user has been granted the ctx_app role and I have other tables that store plain text which I use Oracle Text are fine. I even output the blob column and save as pdf file and they are fine.
However the database seems like not indexing my blob column although the index can be created without error.
Please advise.
Really appreciate anyone who can help.
Thank you.The situation is I have already loaded a few pdf document into the table's blob column.
After I create the Oracle text index on this blob column, I find the system generated index tables listed in my earlier posting are empty, except for the 4th table.
Normally we'll see words inside the table where those are the words indexed by oracle text on my document.
As a result, no matter how i search for the index using select statement with contains operator, it will not give me any result.
I feel weird why the blob is not indexed. The content of the blob are actually valid because I tested this by export the content back to pdf and I can still view and search within the pdf.
Regards,
Jap. -
NEAR operator alternative when not using. oracle Text ?
hi,
I'm working on a project where i would need a Oracle Text 'NEAR like' operator ...
here is my scenario ...
in db we have Customers ... and every customer has some criterias like different search words( names, towns,cars,etc...) so for every customer i can create an SQL query out of criterias . ....
now .... we can have a criteria like. ...... WHERE fulltext like 'john%'. or even distance search line NEAR inside CONTAINS. ... but then the Oracle text index is needed .....
the only tAble on which Text index is created is our storage table that holds more then 4mil records and growing...
my question is ... is there any way to have a query that would do the same thing as NEAR but without Text index ?
here is how I start ....
I get full newspaper article text from our OCR library ......
then i need to check customer's criterias against this text to see which article is for which customer and then bind the article to the customer
I could do it without Oracle using RegEx , but criterias can get really complicated ... like customer wants only specific MEDIA, or specific category , type , only articles that are from medias that are from specific country etc ... and many more different criterias ... and all this can be wrapped inside brackets with ANDs, ORs, NOT. ....
So the only way to do it is to put it in Oracle and execute the correct query and let Oracle decide if the result is true or false .... but due to NEAR operator I need Oracle text ...
So if I decide to first insert article into our storage table which has Oracle text index to be able to do the correct search .... how fast will this be ????
will the the search become slower when there are 6mil records ? I know I can use FILTER BY to help Text index to do a better and quicker seach ... and how to optimize index ....but still
I'm always asking my self..... why insert the article in a table where there are already 6mil articles and execute query when I only need to check data on one single article and. i already know this article ...
I see two solutions :
- if there is alternative for NEAR without using Oracle text index then i would insert data into temporary table and execute query on this table..... table would always contain only this one article. maybe one option would be to have one 'temp' table with Oracle text index in which i insert this one article and with help of Oracle text based on this one article do the search , and then maybe on a daily basis clear index ..... or when the article is removed from the table ... but this would mean having two Orcle text indexes, cause we already have Oracle text index on our storage table anyway....
- another is to use Oracle text index and insert it into our storage table and hope for the best quick results ....
Maybe I'm exaggerating and query like WHERE id=1234 and CONTAINS(...). will execute faster then I think
If anyone would have any other suggestion I will be happy to try it ..
thanks,
KrisHi,
this is to my knowledge not possible. It is hard for Oracle to do, think about a table with many rows, every row with that column must be checked. So I think only a single varchar2 is possible. Maybe for you will a function work. It is possible to give a function as second parameter.
function return_signup
return varchar2
is
l_signup_name signup.signup_name%type;
begin
select signup_name
into l_signup_name
from signup
where signup_id = 1
and rownum = 1
return l_signup_name;
exception
when no_data_found
then
l_signup_name := 'abracadabra'; -- hope does not exist
return l_signup_name;
end;Now you can use above function in the contains.
select * from user_history_view users --, signup new_user
--where new_user.signup_id = 1
where contains(users.user_name, return_signup)>0;I didn't test the code! Maybe you have to adjust the function for your needs. But it is a idea how this can be done.
Otherwise you must make the check by normaly check the columns by simple using a join:
select * from user_history_view users, signup new_user
where new_user.signup_id = 1
and users.user_name = new_user.signup_name;Herald ten Dam
htendam.wordpress.com -
Product Search Using Oracle Text or By Any Other Methods using PL/SQL
Hi All,
I have requirement for product search using the product table which has around 5 million products. I Need to show top 100 disitnct products searched in the following order
1. = ProductDescription
2. ProductDescription_%
3. %_ProductDescription_%
4. %_ProductDescription
5. ProductDescription%
6. %ProductDescription
Where '_' is space. If first two/three/or any criteria itslef gives me 100 records then i need not search for another patterns
Table Structure Is as follows
Create Table Tbl_Product_Lookup
Barcode_number Varchar2(9),
Product_Description Varchar2(200),
Product_Start_Date Date,
Product_End_Date Date,
Product_Price Number(12,4)
Could you please help me implementing this one ? SLA for the search result is 2 seconds
Thanks,
VarunYou could use an Oracle Text context index with a wordlist to speed up substring searches and return all rows that match any of your criteria, combined with a case statement to provide a ranking that can be ordered by within an inner query, then use rownum to limit the rows in an outer query. You could also use the first_rows(n) hint to speed up the return of limited rows. Please see the demonstration below. If you decide to use Oracle Text, you may want to ask further questions in the Oracle Text sub-forum on this forum or space or whatever they call it now.
SCOTT@orcl_11gR2> -- table:
SCOTT@orcl_11gR2> Create Table Tbl_Product_Lookup
2 (
3 Barcode_number Varchar2(9),
4 Product_Description Varchar2(200),
5 Product_Start_Date Date,
6 Product_End_Date Date,
7 Product_Price Number(12,4)
8 )
9 /
Table created.
SCOTT@orcl_11gR2> -- sample data:
SCOTT@orcl_11gR2> insert all
2 into tbl_product_lookup (product_description) values ('test product')
3 into tbl_product_lookup (product_description) values ('test product and more')
4 into tbl_product_lookup (product_description) values ('another test product and more')
5 into tbl_product_lookup (product_description) values ('another test product')
6 into tbl_product_lookup (product_description) values ('test products')
7 into tbl_product_lookup (product_description) values ('selftest product')
8 select * from dual
9 /
6 rows created.
SCOTT@orcl_11gR2> insert into tbl_product_lookup (product_description) select object_name from all_objects
2 /
75046 rows created.
SCOTT@orcl_11gR2> -- wordlist:
SCOTT@orcl_11gR2> begin
2 ctx_ddl.create_preference('mywordlist', 'BASIC_WORDLIST');
3 ctx_ddl.set_attribute('mywordlist','PREFIX_INDEX','TRUE');
4 ctx_ddl.set_attribute('mywordlist','PREFIX_MIN_LENGTH', '3');
5 ctx_ddl.set_attribute('mywordlist','PREFIX_MAX_LENGTH', '4');
6 ctx_ddl.set_attribute('mywordlist','SUBSTRING_INDEX', 'YES');
7 ctx_ddl.set_attribute('mywordlist', 'wildcard_maxterms', 0) ;
8 end;
9 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- context index that uses wordlist:
SCOTT@orcl_11gR2> create index prod_desc_text_idx
2 on tbl_product_lookup (product_description)
3 indextype is ctxsys.context
4 parameters ('wordlist mywordlist')
5 /
Index created.
SCOTT@orcl_11gR2> -- gather statistics:
SCOTT@orcl_11gR2> exec dbms_stats.gather_table_stats (user, 'TBL_PRODUCT_LOOKUP')
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> -- query:
SCOTT@orcl_11gR2> variable productdescription varchar2(100)
SCOTT@orcl_11gR2> exec :productdescription := 'test product'
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> column product_description format a45
SCOTT@orcl_11gR2> set autotrace on explain
SCOTT@orcl_11gR2> set timing on
SCOTT@orcl_11gR2> select /*+ FIRST_ROWS(100) */ *
2 from (select /*+ FIRST_ROWS(100) */ distinct
3 case when product_description = :productdescription then 1
4 when product_description like :productdescription || ' %' then 2
5 when product_description like '% ' || :productdescription || ' %' then 3
6 when product_description like '% ' || :productdescription then 4
7 when product_description like :productdescription || '%' then 5
8 when product_description like '%' || :productdescription then 6
9 end as ranking,
10 product_description
11 from tbl_product_lookup
12 where contains (product_description, '%' || :productdescription || '%') > 0
13 order by ranking)
14 where rownum <= 100
15 /
RANKING PRODUCT_DESCRIPTION
1 test product
2 test product and more
3 another test product and more
4 another test product
5 test products
6 selftest product
6 rows selected.
Elapsed: 00:00:00.10
Execution Plan
Plan hash value: 459057338
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 38 | 3990 | 13 (16)| 00:00:01 |
|* 1 | COUNT STOPKEY | | | | | |
| 2 | VIEW | | 38 | 3990 | 13 (16)| 00:00:01 |
|* 3 | SORT UNIQUE STOPKEY | | 38 | 988 | 12 (9)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| TBL_PRODUCT_LOOKUP | 38 | 988 | 11 (0)| 00:00:01 |
|* 5 | DOMAIN INDEX | PROD_DESC_TEXT_IDX | | | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter(ROWNUM<=100)
3 - filter(ROWNUM<=100)
5 - access("CTXSYS"."CONTAINS"("PRODUCT_DESCRIPTION",'%'||:PRODUCTDESCRIPTION||'%')>0)
SCOTT@orcl_11gR2> -
Address Matching Using Oracle Text
Hi,
I am a newbie to Oracle Text. Hence please pardon my ignorance if this is a "RTFM" Query.
We would like to clash our customer addresses against a table (GEO) that has addresses and geographic coordinates (latitude, longitude etc). The customer address data are in four VARCHAR2 columns (address1, address2, address3 & address4) and need not be in the same order as the address data in the GEO table.
Has anybody used Oracle Text to do similar work to score addresses?
Any links & pointers will be highly appreciated.
Thanks in advance.
Best Regards
RamdasWhen you use a multi_column_datastore, even though the index is only created using one column name and only that column name is used in the contains clause, it searches all columns named in the multi_column_datastore. It may be clearer if you use a dummy column with a name that has more meaning; I have used addresses in the revised example below.
Queries run faster if you put everything in one contains clause instead of using multiple contains clauses.
If you add a section group and field sections, then you can search within those sections and apply weights. In the following example I have doubled the score for results in address1 and address2 and halved the score for results in address3 and address4.
SCOTT@orcl_11gR2> CREATE TABLE customers
2 (id NUMBER,
3 address1 VARCHAR2(30),
4 address2 VARCHAR2(30),
5 address3 VARCHAR2(30),
6 address4 VARCHAR2(30),
7 addresses VARCHAR2(1))
8 /
Table created.
SCOTT@orcl_11gR2> INSERT INTO customers VALUES
2 (1, '123 Somewhere, Someplace', 'nowhere', 'nowhere', 'nowhere', null)
3 /
1 row created.
SCOTT@orcl_11gR2> INSERT INTO customers VALUES
2 (2, 'nowhere', 'nowhere', 'nowhere', '123 Somewhere, Someplace', null)
3 /
1 row created.
SCOTT@orcl_11gR2> INSERT INTO customers VALUES
2 (3, 'nowhere', '500 Oracle Pkwy', 'nowhere', 'nowhere', null)
3 /
1 row created.
SCOTT@orcl_11gR2> INSERT INTO customers VALUES
2 (4, 'nowhere', 'nowhere', '500 Oracle Pkwy', 'nowhere', null)
3 /
1 row created.
SCOTT@orcl_11gR2>
SCOTT@orcl_11gR2> BEGIN
2 CTX_DDL.CREATE_PREFERENCE
3 ('cust_datastore',
4 'MULTI_COLUMN_DATASTORE');
5 CTX_DDL.SET_ATTRIBUTE
6 ('cust_datastore',
7 'COLUMNS',
8 'address1, address2, address3, address4');
9 CTX_DDL.CREATE_SECTION_GROUP
10 ('cust_sg', 'BASIC_SECTION_GROUP');
11 CTX_DDL.ADD_FIELD_SECTION ('cust_sg', 'address1', 'address1', true);
12 CTX_DDL.ADD_FIELD_SECTION ('cust_sg', 'address2', 'address2', true);
13 CTX_DDL.ADD_FIELD_SECTION ('cust_sg', 'address3', 'address3', true);
14 CTX_DDL.ADD_FIELD_SECTION ('cust_sg', 'address4', 'address4', true);
15 END;
16 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11gR2> CREATE INDEX customers_idx
2 ON customers (addresses)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 PARAMETERS
5 ('DATASTORE cust_datastore
6 SECTION GROUP cust_sg')
7 /
Index created.
SCOTT@orcl_11gR2> CREATE TABLE geo
2 (address VARCHAR2(40),
3 coordinates VARCHAR2(30))
4 /
Table created.
SCOTT@orcl_11gR2> INSERT INTO geo VALUES
2 ('500 Oracle Pkwy, Redwood City, CA 94065',
3 '37° 31'' N / 122° 15'' W')
4 /
1 row created.
SCOTT@orcl_11gR2> INSERT INTO geo VALUES
2 ('123 Somewhere Street, Someplace City, CA',
3 NULL)
4 /
1 row created.
SCOTT@orcl_11gR2> SELECT SCORE(1), c.*, g.address, g.coordinates
2 FROM customers c,
3 (SELECT address,
4 '(' || REPLACE (REPLACE (address, ' ', ','), ',,', ',') || ')' addr,
5 coordinates
6 FROM geo) g
7 WHERE CONTAINS
8 (c.addresses,
9 '((' || g.addr || ' WITHIN address1 OR ' ||
10 g.addr || ' WITHIN address2) * 2) OR ' ||
11 '((' || g.addr || ' WITHIN address3 OR ' ||
12 g.addr || ' WITHIN address4) * 0.5)',
13 1) > 0
14 ORDER BY SCORE(1) DESC
15 /
SCORE(1) ID ADDRESS1
ADDRESS2 ADDRESS3
ADDRESS4 A ADDRESS
COORDINATES
68 1 123 Somewhere, Someplace
nowhere nowhere
nowhere 123 Somewhere Street, Someplace City, CA
59 3 nowhere
500 Oracle Pkwy nowhere
nowhere 500 Oracle Pkwy, Redwood City, CA 94065
37° 31' N / 122° 15' W
17 2 nowhere
nowhere nowhere
123 Somewhere, Someplace 123 Somewhere Street, Someplace City, CA
15 4 nowhere
nowhere 500 Oracle Pkwy
nowhere 500 Oracle Pkwy, Redwood City, CA 94065
37° 31' N / 122° 15' W
4 rows selected. -
Patches 7446163 y 6851110 in order to use Oracle Text from UCM
Hello, we have Oracle Enterprise Edition 11.2.0.1 on AIX 6.1.0.0 (64 bits). The client want to use Oracle Text from Universal Content Management, he told me about install the patches 7446163 y 6851110 in order to enable Oracle Text from UCM. I reviewed in Metalink but the readme said that those patches are for Oracle 11.1.0.7. That version (11.2.0.1) include already those patches or those are necessary for we can use the funcionality of Oracle Text from Universal Content Management? I reviewed the components installed on database and the Oracle Text is installed and active.
Thanks for your help.
Sincerely,
Ruben Nieto
DBAHi
Oracle DB usually would be installed with Oracle Text enabled (the db side) . To use the features for this we need to have OracleText component enabled on UCM which as you mentioned is already installed and enabled on the ucm server .
If both the above conditions are already met then you would not need to install any further patches.
Let me know if it is fine on db and ucm .
Verify that Oracle Text is enabled on db by executing the following query :
select comp_name, status from dba_registry;
It should return the the following result : Oracle Text VALID
To verify if the component for UCM is installed then you would need to check Administration - Configuration for <instance name> - Enabled Components
Thanks
Srinath
Edited by: Srinath Menon on Dec 26, 2010 8:38 PM -
Using Oracle Text in Oracle XML DB .
Hi all ,
The idea is simple ,i need to index all stored files in Oracle XML DB and the index should stay in Oracle DB . Using some 3 party index software is also possible but you need to write a mapping to move the index file in Oracle DB .
So i thought of using Oracle Text but i am not sure about how to retrieve such a document from Oracle XML DB , let me say over ftp or http ? . And if these documents are password protected -> how can Oracle Text allow this ?[11gR2 XMLDB Developers Guide -- Full-Text Search over XML Data|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb09sea.htm#i1006756] would be the first place to start.
For document display, there a bunch of potential solutions, you can look at [XML DB Repository|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb03usg.htm#insertedID18], or the Text Application Developers Guide [Presenting Documents in Oracle Text|http://download.oracle.com/docs/cd/B28359_01/text.111/b28303/view.htm#i1006687] .
Password protected documents can't be indexed using the auto_filter. -
Issues using Oracle Text conditions
Hi all,
I'm facing an issue executing a query on a VIEW using Oracle Text Indexes.
The DB version I'm using is "Enterprise 9.2.0.5".
TEST_VIEW is an sql-view that has a query on several tables where one of them has two Oracle Text indexes, one on field FIELD2 and another on FIELD3
executing this query I get 10 rows:
select *
from TEST_VIEW
where FIELD1 = 1001 -- regular condition
and (contains(FIELD2, 'Blitz') > 0 ) -- Oracle text condition
But if I add another condition on an existent Oracle Text Index, I'll get only 1 row:
select *
from TEST_VIEW
where FIELD1 = 1001
where (contains(FIELD2, 'Blitz') > 0 OR contains(FIELD3, 'Blitz') > 0)
As you can see the third condition was added using a logical OR, so I should get at least 10 rows ...
Can anyone help me ?
ThaNks in advance.
Eduardo.Eduardo,
Without a full test case, it is hard to see if there is something wrong or not. I did the following, and all worked fine on my 10g instance. I had to assume some things, but I at least think I have the basic gist of your inquiry in this example. Run it/change it to match your situation, and post back when you can.
Thanks,
Ron
CREATE TABLE Z_TEST1 (
FIELD1 VARCHAR2(30));
INSERT INTO Z_TEST1
VALUES ('QUICK');
INSERT INTO Z_TEST1
VALUES ('BROWN');
INSERT INTO Z_TEST1
VALUES ('FOX');
INSERT INTO Z_TEST1
VALUES ('QUICK');
INSERT INTO Z_TEST1
VALUES ('BROWN');
INSERT INTO Z_TEST1
VALUES ('FOX');
CREATE TABLE Z_TEST2 (
FIELD2 VARCHAR2(30));
INSERT INTO Z_TEST2
VALUES ('JUMPED');
INSERT INTO Z_TEST2
VALUES ('OVER');
INSERT INTO Z_TEST2
VALUES ('LAZY');
INSERT INTO Z_TEST2
VALUES ('DOG');
INSERT INTO Z_TEST2
VALUES ('QUICK');
INSERT INTO Z_TEST2
VALUES ('BROWN');
INSERT INTO Z_TEST2
VALUES ('FOX');
commit;
CREATE VIEW TEST_VIEW
AS
SELECT Z_TEST1.FIELD1 AS "FIELD1", Z_TEST2.FIELD2 AS "FIELD2"
FROM Z_TEST1, Z_TEST2;
CREATE INDEX Z_TEST1_IDX ON Z_TEST1(FIELD1)
INDEXTYPE IS CTXSYS.CONTEXT;
CREATE INDEX Z_TEST2_IDX ON Z_TEST2(FIELD2)
INDEXTYPE IS CTXSYS.CONTEXT;
select *
from TEST_VIEW
where CONTAINS(FIELD1, 'FOX') > 0;
14 rows
select *
from TEST_VIEW
where (CONTAINS(FIELD1, 'FOX') > 0 OR CONTAINS(FIELD2, 'FOX') > 0);
18 rows -
Using oracle text in apex report search
I am trying to use oracle text in apex, integrating it in an existing application. The idea is that it will allow to do a search in bigger textfields. Thats how I want it to get to work. In one of the oracle packaged applications oracle text is used as well, so I will have a look to that as well. I've addapted this search. I've added
AND t. contains(oplossing, :P15_OPLOSSING)
AND t.contains(sleutelwoorden, :P15_SLEUTELWOORDEN)
That didn't work, so I changed those two to:
AND t.oplossing = (t.contains(oplossing, :P15_OPLOSSING)>0)
AND t.sleutelwoorden = (t.contains(sleutelwoorden, :P15_SLEUTELWOORDEN)>0)
which didn't work either, which I expected to be the case. Clearly I'm not doing it correctly, I intend to look it up tonight in the packaged applications as I do want to findt it myself to.
But does anyone can give a hint, on what I am doing wrong ?
SELECT t.ticketid ticketnr, t.ticketid,
g.voornaam||' '||g.naam aangemaaktdoor,
t.credt, t.applicatiecd, t.titel,
s.statusdefoms,
si.statusdefoms instat,
NVL2(t.toegekend,'Y','N') toegekend,
sleutelwoorden, klantprioriteitid, oplossing, s.htmlkleur, si.htmlkleur inthtmlkleur
FROM ticket t,
gebruiker g,
status s,
status si
WHERE t.gebruikerid = g.gebruikerid
AND t.statusid = s.statusid
AND t.statusinternid = si.statusid (+)
AND t.applicatiecd = NVL(:P0_APPLICATIECD, :F101_APPLICATIECD)
AND (t.categorieid = :P15_CATEGORIEID OR NVL(:P15_CATEGORIEID, 0) = 0)
AND (t.moduleid = :P15_MODULEID OR NVL(:P15_MODULEID, 0) = 0)
AND (t.statusid = :P15_STATUSID OR NVL(:P15_STATUSID, 0) = 0)
AND (t.statusinternid = :P15_INTSTATUSID OR NVL(:P15_INTSTATUSID, 0) = 0)
AND (t.versieid = :P15_VERSIEID OR NVL(:P15_VERSIEID, 0) = 0)
AND t.ticketid LIKE '%'||:P15_TICKETID||'%'
AND t.gebruikerid = DECODE(NVL(:P15_GEBRUIKERID,0), 0, t.gebruikerid, :P15_GEBRUIKERID)
AND t.credt BETWEEN NVL(:P15_DATUMVAN, To_Date('01-01-1900', 'DD-MM-YYYY')) AND NVL(To_Date(:P15_DATUMTOT, 'DD-MM-YYYY'), sysdate) +1
AND t.titel LIKE '%'||:P15_TITEL||'%'
AND t. contains(oplossing, :P15_OPLOSSING)
AND t.contains(sleutelwoorden, :P15_SLEUTELWOORDEN)
AND PCK$Ticket_Admin.getklantid(t.gebruikerid) = DECODE(Pck$Ticket_Admin.isklantadminroleN(:APP_USER,NVL(:P0_APPLICATIECD, :F101_APPLICATIECD)), 1, PCK$Ticket_Admin.getklantid(:APP103_GEBRUIKERID), PCK$Ticket_Admin.getklantid(t.gebruikerid))
AND (:APP103_GEBRUIKERID IN (t.voor_gebruikerid, t.gebruikerid)
OR Pck$Ticket_Admin.isintern(:APP_USER,:P0_APPLICATIECD) = 1)
changed to:
AND t.oplossing = (t.contains(oplossing, :P15_OPLOSSING)>0)
AND t.sleutelwoorden = (t.contains(sleutelwoorden, :P15_SLEUTELWOORDEN)>0)I have worked it further out now, and looked at the search of the packaged application. It turned out to be a pl/sql block . I used what I found in there to adapt the previous search. I added the following:
OR (CONTAINS(t.oplossing, :P15_OPLOSSING)>0)
OR (CONTAINS(t.sleutelwoorden, :P15_SLEUTELWOORDEN)>0)
OR (CONTAINS(t.titel,:P15_SEARCH_T_O_S)>0 OR
CONTAINS (t.oplossing, :P15_SEARCH_T_O_S)>0 OR
CONTAINS(t.sleutelwoorden, :P15_SEARCH_T_O_S)>0 )
OR (CONTAINS(t.titel,:P15_SEARCH_T_O_S)>0 AND
CONTAINS (t.oplossing, :P15_SEARCH_T_O_S)>0 AND
CONTAINS(t.sleutelwoorden, :P15_SEARCH_T_O_S)>0 )
oplossing means solution
sleutelwoorden means keywords
titel means title
Yet this doesn't work yet. It gives an error message:
failed to parse SQL query:
ORA-01719: outer join operator (+) not allowed in operand of OR or IN
I've tried adding the addition in a different place, yet that gives the same error message. I'm not sure now. -
Oracle Text: How to add/get stopwords list when using Oracle Text world lexer?
I have a use case that we currently use Oracle Text World Lexer to index and search multilingual documents. As we know that World Lexer does the language auto detection. I would like to know the following questions:
Is there anyway I can get the current document's language that Oracle Text detected?
Is there anyway to get the language's stopwords list?
Any thoughts and points will be appreciated.
- Charles1. If you're using 12c, you can use ctx_doc.policy_languages. (https://docs.oracle.com/database/121/CCREF/cdocpkg011.htm#CCREF24102)
2. If you want multiple stoplists based on each document's language, you have to use the multi-lexer. For world_lexer, there is one stoplist; since the stoplists are somewhat dynamic (you can add but not remove them), the most accurate way to fetch the list is using ctx_report.describe_index or ctx_report.create_index_script and parse the report. -
Oracle iRecruitment: Keyword Search within Resumes using Oracle Text
Dear All,
As per my understanding (and Note: 247064.1) simple Keyword searches can be performed in iRecruitment if oracle Text is installed. However searching for Keywords within resumes is not possible using Oracle Text and is possible ONLY if Resume Parsing is enabled via a third party (non-oracle) service provider.
Can you please let me know if my understanding is correct and if not provide further inputs on this.
Thanks,
SubratGot this confirmation from Oracle via SR:
Resume searching is independent of resume parsing and not required to search resumes.
Oracle Text is the text engine that allows you to search documents using content-based queries. Oracle Text allows you to upload documents, search documents, parse resumes, etc.
Hence to conclude - Installation of Oracle Text will allow Keyword Searches on resumes.
Thanks,
Subrat -
Using Oracle Text to search through WORD, EXCEL and PDF documents
Hello again,
What I would like to know is if I have a WORD or PDF document stored in a table. Is it possible to use Oracle Text to search through the actual WORD or PDF document?
Thanks
DougYes you can do context sensitive searches on both PDF and Word docs. With the PDF you need to make sure they are text and not images. Some scanners will create PDFs that are nothing more than images of document.
Below is code sample that I made some time back to demonstrate the searching capabilities of Oracle Text. Note that the example makes use of the inso_filter that is no longer shipped with Oracle begging with Patch set 10.1.0.4. See metalink note 298017.1 for the changes. See the following link for more information on developing with Oracle Text.
http://download-west.oracle.com/docs/cd/B14117_01/text.101/b10729/toc.htm
begin example.
-- The following needs to be executed
-- as sys.
DROP DIRECTORY docs_dir;
CREATE OR REPLACE DIRECTORY docs_dir
AS 'C:\sql\oracle_text\documents';
GRANT READ ON DIRECTORY docs_dir TO text;
-- End sys ran SQL
DROP TABLE db_docs CASCADE CONSTRAINTS PURGE;
CREATE TABLE db_docs (
id NUMBER,
format VARCHAR2(10),
location VARCHAR2(50),
document BLOB,
CONSTRAINT i_db_docs_p PRIMARY KEY(id)
-- Several notes need to be made about this anonymous block.
-- First the 'DOCS_DIR' parameter is a directory object name.
-- This directory object name must be in upper case.
DECLARE
f_lob BFILE;
b_lob BLOB;
document_name VARCHAR2(50);
BEGIN
document_name := 'externaltables.doc';
INSERT INTO db_docs
VALUES (1, 'binary', 'C:\sql\oracle_text\documents\externaltables.doc', empty_blob())
RETURN document INTO b_lob;
f_lob := BFILENAME('DOCS_DIR', document_name);
DBMS_LOB.FILEOPEN(f_lob, DBMS_LOB.FILE_READONLY);
DBMS_LOB.LOADFROMFILE(b_lob, f_lob, DBMS_LOB.GETLENGTH(f_lob));
DBMS_LOB.FILECLOSE(f_lob);
COMMIT;
END;
-- build the index
-- Note that this index differs than the file system stored file
-- in that paramter datastore is ctxsys.defautl_datastore and not
-- ctxsys.file_datastore. FILE_DATASTORE is for documents that
-- exist on the file system. DEFAULT_DATASTORE is for documents
-- that are stored in the column.
create index db_docs_ctx on db_docs(document)
indextype is ctxsys.context
parameters (
'datastore ctxsys.default_datastore
filter ctxsys.inso_filter
format column format');
--search for something that is known to not be in the document.
SELECT SCORE(1), id, location
FROM db_docs
WHERE CONTAINS(document, 'Jenkinson', 1) > 0;
--search for something that is known to be in the document.
SELECT SCORE(1), id, location
FROM db_docs
WHERE CONTAINS(document, 'Albright', 1) > 0;
Maybe you are looking for
-
Why am I all of a sudden getting all my text and email notifications in Spanish? How do I switch back to English? I can't find that option in profile or notification settings . . .
-
I have a mac mini. what type of connector/cable do I need to output digital audio?
-
Screen goes down when pressed in the corner?
Basically, in the bottom right hand corner of my iPod, I can press down, and the screen will go down? Get what I mean? It doesn't happen in any of the other causes, and just wondered if there is anything I can do about it, or if it could cause furthe
-
How do I start and stop the corection system - das Korrektursystem/ the program in pages where one mark a text while proff reading it?
-
Configuration EDI output - Delaying the output by specific amount of time
Hi, I am trying to delay EDI output when it is generated by 1 min exactly before the IDOC leaves SAP to go to Business Connector. I would like some notes or step by step guide on how to do it. Which program requires change? We tried to change NACE,