Oracle Text query parser - sample code
I've posted a new entry on my "searchtech" blog which includes code for a "Google-like" query syntax parser:
https://blogs.oracle.com/searchtech/entry/oracle_text_query_parser
Currently it's just sample code, but if it goes down well we might include it, or something similar, in a future release of the product.
I'd very much welcome feedback on it, either here on the forum, or on the blog, or directly to me email address (which is included in the download file).
Thanks, everyone.
When I select the "open in browser" option for each now, I get formatted, readable code, which can easily be copied and pasted into a file without the extra txt extension, and I much prefer that. So, for me, that is a sufficient fix.
It seems like this is handy, virtually idiot-proof code, easy to create the package, easy to use it, and provides the Google-like search that users expect, without raising errors or producing unexpected results. Frequently, on the OraFAQ forums, where I am a moderator, when there are various ways to solve a problem and I provide a Text solution, the complaint is that it is too complicated to create all of the formatting to fix potential problems with user input. Your code solves that problem and I hope it will be included in the next version. If you don't mind, I will post an announcement in the OraFAQ Text forum with the permanent link that you provided.
Similar Messages
-
DRG-50901: text query parser syntax error
The query
SELECT * FROM ij
where
CONTAINS (ij.summary, 'ATTENZIONE!') > 0 returns an error:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 13
Why?
There is a TEXT index on the summary column:
CREATE INDEX IJL_SUMMARY_IX ON IJ
(SUMMARY)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS('
lexer MITO_LEXER
wordlist DEFAULT_WORDLIST
stoplist IJL_STOPLIST
storage IJL_TEXT_STORAGE
SYNC (EVERY "SYSDATE + 10/1440")')
PARALLEL ( DEGREE 4 INSTANCES 1 );where the MITO_LEXER is
BEGIN
CTX_DDL.create_preference ('mito_lexer', 'BASIC_LEXER');
CTX_DDL.set_attribute ('mito_lexer', 'INDEX_STEMS', 'ITALIAN');
-- MITO-318: search on Text Index for Asterisks
CTX_DDL.set_attribute ('mito_lexer', 'printjoins', '*');
END;
/Because the exclamation mark ("!") is a reserved operator, meaning soundex, and must appear before the word it applies to.
-
Hello guys,
I rather need an advice and my experience with the Oracle forums has always been auspicious.
I am using jDeveloper 11gR2 and Oracle database 11.2.0.1. Running the following query I have a view object based on that query and a search form with results table.
SELECT
SEEKER.SEEKER_ID SEEKER_ID,
SEEKER.CV CV,
SCORE(1)
FROM
SEEKER
WHERE CONTAINS(CV, '<query>
<textquery lang="ENGLISH" grammar="context">' ||
GET_RELATED_CATEGORIES(:keyword) ||
'</textquery>
<score datatype="INTEGER"/>
</query>', 1) > 0
GET_RELATED_CATEGORIES is a function which returns concatenated strings querying some semantic data in my database. The problem is when GET_RELATED_CATEGORIES returns null the "text query parser" is throwing an exception (that is how it is supposed to act).
I am asking for any suggestions for the implementation of that functionality and will be really grateful. Shall I export the whole query in a remote procedure and maybe call it as a web service or there is any other better solution (maybe some checks).
Thank you in advance!I see two possible ways you can try.
1. cause the function in a way that no null value is returned (return an empty string '')
2. put a nvl (get..., '') around the function
Timo -
Oracle Text query: Escaping characters and specifying progression sequences
How can I combine the escaping of a search string and the specification of progression sequences within an oracle text query
so that in all cases the correct results are delivered (see example below)?
The scenario in which to use this is the following:
+ Database: Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
+ Requirement: Hitlist of results ordered by score whereby the different part within
the result list are specified using progression sequences within oracle text query
Example:
create table service_provider (
id number,
name_c varchar(100),
uri_c varchar(255)
insert into service_provider values (1,'ABB Company Mgmt','http://www.abb-company-mgmt.de');
insert into service_provider values (2,'Dr. Abbas Ming','http://www.dr-abbas-ming.de');
insert into service_provider values (3,'SABBATA United','http://www.sabbata-united.de');
insert into service_provider values (4,'ABB','http://www.abb.de');
insert into service_provider values (5,'AND Company Mgmt','http://www.and-company-mgmt.de');
insert into service_provider values (6,'Dr. Andas Ming','http://www.dr-andas-ming.de');
insert into service_provider values (7,'SANDATA United','http://www.sandata-united.de');
insert into service_provider values (8,'AND','http://www.and.de');
Query 1: works correctly in this case
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>abb</seq>' ||
'<seq>abb%</seq>' ||
'<seq>%abb%</seq>' ||
'<seq>fuzzy(abb,1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
51 2 Dr. Abbas Ming http://www.dr-abbas-ming.de
26 3 SABBATA United http://www.sabbata-united.de
Query 2: procudes error
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>and</seq>' ||
'<seq>and%</seq>' ||
'<seq>%and%</seq>' ||
'<seq>fuzzy(and,1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
produces ORA-29902, ORA-20000, DRG-50901 because AND is a reserved word in oracle text
So we need escaping ...
Query 3: does not work correctly
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>{abb}</seq>' ||
'<seq>{abb%}</seq>' ||
'<seq>{%abb%}</seq>' ||
'<seq>fuzzy({abb},1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
Query 4: does not produce an error, but also does not work correctly
select * from (
select /*+ FIRST_ROWS */ score(1), this_.*
from service_provider this_
where
CONTAINS ( this_.NAME_C , '<QUERY><textquery grammar="CONTEXT">' ||
'<progression>' ||
'<seq>{and}</seq>' ||
'<seq>{and%}</seq>' ||
'<seq>{%and%}</seq>' ||
'<seq>fuzzy({and},1,100,WEIGHT)</seq>' ||
'</progression></textquery></QUERY>', 1 ) > 0
order by score(1) desc, this_.NAME_C
) where rownum < 21
delivers
76 8 AND http://www.and.de
76 5 AND Company Mgmt http://www.and-company-mgmt.deAnywhere that you just use the word by itself, enclose it in {}, but anywhere that you add % on either side or both don't enclose it in {}. Please see the demonstration below.
SCOTT@10gXE> SELECT * FROM v$version
2 /
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SCOTT@10gXE> create table service_provider
2 (id number,
3 name_c varchar(100),
4 uri_c varchar(255))
5 /
Table created.
SCOTT@10gXE> insert all
2 into service_provider values (1,'ABB Company Mgmt','http://www.abb-company-mgmt.de')
3 into service_provider values (2,'Dr. Abbas Ming','http://www.dr-abbas-ming.de')
4 into service_provider values (3,'SABBATA United','http://www.sabbata-united.de')
5 into service_provider values (4,'ABB','http://www.abb.de')
6 into service_provider values (5,'AND Company Mgmt','http://www.and-company-mgmt.de')
7 into service_provider values (6,'Dr. Andas Ming','http://www.dr-andas-ming.de')
8 into service_provider values (7,'SANDATA United','http://www.sandata-united.de')
9 into service_provider values (8,'AND','http://www.and.de')
10 into service_provider values (9,'EBB','fuzzy test')
11 into service_provider values (10,'OND','fuzzy test')
12 select * from dual
13 /
10 rows created.
SCOTT@10gXE> CREATE INDEX your_index
2 ON service_provider (name_c)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 PARAMETERS ('STOPLIST CTXSYS.EMPTY_STOPLIST')
5 /
Index created.
SCOTT@10gXE> VARIABLE search_string VARCHAR2 (100)
SCOTT@10gXE> EXEC :search_string := 'abb'
PL/SQL procedure successfully completed.
SCOTT@10gXE> COLUMN name_c FORMAT A20 WORD_WRAPPED
SCOTT@10gXE> COLUMN uri_c FORMAT A40
SCOTT@10gXE> select *
2 from (select /*+ FIRST_ROWS */ score(1), this_.*
3 from service_provider this_
4 where CONTAINS
5 (this_.NAME_C ,
6 '<QUERY>
7 <textquery grammar="CONTEXT">
8 <progression>
9 <seq>{' || :search_string || '}</seq>
10 <seq>' || :search_string || '%</seq>
11 <seq>%' || :search_string || '%</seq>
12 <seq>fuzzy({' || :search_string || '},1,100,WEIGHT)</seq>
13 </progression>
14 </textquery>
15 </QUERY>', 1 ) > 0
16 order by score(1) desc, this_.NAME_C)
17 where rownum < 21
18 /
SCORE(1) ID NAME_C URI_C
76 4 ABB http://www.abb.de
76 1 ABB Company Mgmt http://www.abb-company-mgmt.de
51 2 Dr. Abbas Ming http://www.dr-abbas-ming.de
26 3 SABBATA United http://www.sabbata-united.de
4 9 EBB fuzzy test
SCOTT@10gXE> EXEC :search_string := 'and'
PL/SQL procedure successfully completed.
SCOTT@10gXE> /
SCORE(1) ID NAME_C URI_C
76 8 AND http://www.and.de
76 5 AND Company Mgmt http://www.and-company-mgmt.de
51 6 Dr. Andas Ming http://www.dr-andas-ming.de
26 7 SANDATA United http://www.sandata-united.de
5 10 OND fuzzy test
SCOTT@10gXE> -
Hi,
I have a View object with various attributes (eg, name1, name2, name3, address1, address2, address3 etc). A query/table component based on this view object works just fine. However, I wish to replace name1, name2, name3 and other attributes in the query with just 'name'. These attributes are still to be shown in the result table. This new 'name' attribute will be used in an Oracle Text query clause, instead of individual searches on each attribute.
My plan was to simply make the various name1, name2 etc attributes non-'queryable' in the View def to hide them from the query. Then I'd add a transient 'name' attribute. My hope was, that I could override the getWhereClause() in the ViewObjectImpl and simply tack on the oracle text clause to the WHERE (example below):
WHERE CONTAINS (
SOMECOLUMN,
'<query>
<textquery lang="ENGLISH" grammar="CONTEXT">TRANSIENT_ATTR_VALUE
..... Oracle Text query grammar stuff here .... </query>') > 0How do I access the transient value in the ViewObjectImpl to add the above SQL? Or am I going about this in completely the wrong way?
thanks,
Barry.Based on what I found in
http://www.oracle.com/technology/oramag/oracle/09-nov/o69frame.html?_template=/ocom/print
and
http://blogs.oracle.com/smuenchadf/examples/
136. Introducing a Checkbox to Toggle a Custom SQL Predicate on an LOV's Search Form. [11.1.1.0.0] 19-NOV-2008
I have the following implementation, which seems to work. Does anyone see any problems with this?
With regard to SQL injection, does ViewCriteriaItem sanitise the 'val' from the query, or should I do that manually here myself?
@Override
public java.lang.String getCriteriaItemClause(ViewCriteriaItem vci) {
if ("OraTextTransientAttrib".equals(vci.getAttributeDef().getName())) {
if (vci.getViewCriteria().isCriteriaForQuery()) {
String val = (String)vci.getValue();
logger.debug("Doing oracle text name search on '" + val + "'");
// simplified version of my oracle text query
return "CONTAINS ('<query>..... " + val + "....</query>') > 0 ";
} else {
// SQL predicate for no changes to the results
// spaces needed if you have several of these blocks
return " 1=1 ";
// other blocks for other similar oracle text attribs
return super.getCriteriaItemClause(vci);
} -
"MS" reserved word in oracle text query?
Wondering if anyone has run into the string "MS" behaving as a reserved word in oracle text queries. For example, this specification returns all records from Texas:
'<query>
<textquery>
<progression>
<seq> TX WITHIN CUSTOMER_STATE </seq>
</progression>
</textquery>
</query>'
But this one does NOT find any results for Mississippi:
'<query>
<textquery>
<progression>
<seq> MS WITHIN CUSTOMER_STATE </seq>
</progression>
</textquery>
</query>'
I've confirmed we have data that should match, and I've tried escaping it with the sequences as described in the SQL docs (I've tried single quotes, pairs of single quotes, braces, and combinations of those) . And trying to find info on the web is tough since all web queries that contain 'MS' bring back tons of Microsoft-relevant information.
Can anyone nudge me in the right direction for a better google-search, or some materials in these forums (my initial searches here didn't turn anything up either).
Thanks for any feedback!
jhWondering if anyone has run into the string "MS" behaving as a reserved word in oracle text queries.Maybe because »MS« is in the default english stoplist?:
English Default Stoplist. -
Oracle Text Query taking too long
When we run a query:
select docid from Tbl1 where contains(doc,'queryterm',1)>0;
on 2 million docs it runs in <2 seconds
When we run an insert into another table based on a search:
insert into Tbl2 (col1,col2) select 10,col2 from Tbl1 where rowid<2000; (10 in the select statement is a constant)
it runs in <2 seconds
Here's the kicker:
insert into Tbl2 (col1,col2) select col1,col2 from Tbl1 where contains(doc,'queryterm',1)>0;
it runs in 60 seconds and produces ~2k rows
Is there any hint that we can use to fix this?
TIA!We've looked hard at the performance notes for Oracle Text, the Application guide and the FAQ on it.
We've dropped the index on the table being inserted, turn off logging and used the Parallel hint on the insert. There is still a bit of a disconnect between insert speed, select speed and both together. The index was built using the parallel option so the queries should be parallel if I understand the performance hints correctly. -
Oracle Text Query of abbreviated word / name
I'm new to Oracle Text so please excuse the (probably) simple question. I want to be able to create a search that excludes (includes?) special characters and/or spaces between an abbreviated name. I'm not sure if it's possible but I would like to be able to return all of the below results if someone queried for "ABC" in one form or another.
Would this be something I'd add to a thesaurus? I see there is a STOPLIST but I'm not sure if there is the opposite of a stoplist.
Thanks in advance!
Regards,
Rich
set def off;
drop table docs;
CREATE TABLE docs (id NUMBER PRIMARY KEY, text VARCHAR2(200));
INSERT INTO docs VALUES(1, 'ABC are my favorite letters.');
INSERT INTO docs VALUES(2, 'My favorite letters are A,B,C');
INSERT INTO docs VALUES(3, 'The best letters are A.B.C.');
INSERT INTO docs VALUES(4, 'Three of the word letters are A-B-C.');
INSERT INTO docs VALUES(5, 'A B C are great letters.');
INSERT INTO docs VALUES(6, 'AB and C are easy letters to remember');
INSERT INTO docs VALUES(7, 'What if we used A, B, & C?');
commit;
begin
ctx_ddl.drop_preference('english_lexar');
end;
begin
ctx_ddl.create_preference('english_lexar', 'BASIC_LEXER');
ctx_ddl.set_attribute('english_lexar', 'printjoins', '_-');
ctx_ddl.set_attribute('english_lexar', 'skipjoins', '-.');
--ctx_ddl.set_attribute ( 'english_lexar', 'index_themes', 'YES');
ctx_ddl.set_attribute ( 'english_lexar', 'index_text', 'YES');
ctx_ddl.set_attribute ( 'english_lexar', 'index_stems', 'SPANISH');
ctx_ddl.set_attribute ( 'english_lexar', 'mixed_case', 'YES');
ctx_ddl.set_attribute ( 'english_lexar', 'base_letter', 'YES');
end;
begin
ctx_ddl.drop_preference('STEM_FUZZY_PREF');
end;
begin
ctx_ddl.create_preference('STEM_FUZZY_PREF', 'BASIC_WORDLIST');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_MATCH','ENGLISH');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_SCORE','0');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_NUMRESULTS','5000');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','SUBSTRING_INDEX','TRUE');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','PREFIX_INDEX','TRUE');
ctx_ddl.set_attribute('STEM_FUZZY_PREF','STEMMER','ENGLISH');
end;
begin
ctx_ddl.drop_preference('wildcard_pref');
end;
begin
Ctx_Ddl.create_Preference('wildcard_pref', 'BASIC_WORDLIST');
ctx_ddl.set_attribute('wildcard_pref', 'wildcard_maxterms', 100) ;
end;
DROP index myindex;
create index myindex on docs (text)
indextype is ctxsys.context
parameters ( 'LEXER english_lexar Wordlist wildcard_pref' );
EXEC CTX_DDL.SYNC_INDEX('myindex', '2M');
SELECT SCORE(1), id, text FROM docs WHERE CONTAINS(text, 'ABC', 1) > 0;It may be that my SQL statement isn't taking advantage of the Text options -- i.e. I'm forgetting something obvious :)Indexes are case-insensitive by default, so let's ignore that.
You can make wal-mart and wal*mart match walmart by defining "-" and "*" as SKIPJOINS characters. However, you cannot make wal mart match walmart, other than by using NDATA.
NDATA does seem to work - any variation of wal mart walmart wal*mart and wal-mart do manage to match both walmart and wal mart. See example:
SQL> create table testcase (text varchar2(2000));
Table created.
SQL> insert into testcase values ('<nd>walmart</nd>');
1 row created.
SQL> insert into testcase values ('<nd>wal mart</nd>');
1 row created.
SQL> exec ctx_ddl.drop_section_group('tcsg')
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.create_section_group('tcsg', 'xml_section_group')
PL/SQL procedure successfully completed.
SQL> exec ctx_ddl.add_ndata_section('tcsg', 'nd', 'nd')
PL/SQL procedure successfully completed.
SQL> create index testcase_index on testcase(text)
2 indextype is ctxsys.context
3 parameters ('section group tcsg')
4 /
Index created.
SQL> select * from testcase where contains (text, 'ndata(nd, wal mart)') > 0;
TEXT
<nd>walmart</nd>
<nd>wal mart</nd>
SQL> select * from testcase where contains (text, 'ndata(nd, wal-mart)') > 0;
TEXT
<nd>walmart</nd>
<nd>wal mart</nd>
SQL> select * from testcase where contains (text, 'ndata(nd, wal*mart)') > 0;
TEXT
<nd>walmart</nd>
<nd>wal mart</nd>
SQL> select * from testcase where contains (text, 'ndata(nd, walmart)') > 0;
TEXT
<nd>walmart</nd>
<nd>wal mart</nd>Edited by: Roger Ford on Jun 21, 2012 10:22 AM -
Oracle text contains and mixed queries
Trying to optimize the following sql statement using oracle text. When postal code is given, I would like to limit the contains to only filter the smaller subset. Both of these queries produce the same results in the same amount of time with practically identical explain plans. Is there any way to get contains to only search the subset of postal codes and not the entire table.
select *
from ADDRESS
where CONTAINS(ADDRESS1_TEXT, ' "1%" AND "%str%" ') > 0
and POSTAL_CODE like '77539%'
select *
from ADDRESS
where address_id in (select address_id from address where POSTAL_CODE like '77539%')
and CONTAINS(ADDRESS1_TEXT, ' "1%" AND "%str%" ') > 0
Thanks for any help,
GusYou can use FILTER BY in the index creation and SDATA in the query, as shown below.
SCOTT@orcl12c> CREATE TABLE address
2 (address1_text VARCHAR2(15),
3 postal_code VARCHAR2(15))
4 /
Table created.
SCOTT@orcl12c> INSERT INTO address VALUES ('12 astrb', '775391')
2 /
1 row created.
SCOTT@orcl12c> INSERT INTO address
2 SELECT SUBSTR (object_name, 1, 15),
3 object_id
4 FROM all_objects
5 /
89979 rows created.
SCOTT@orcl12c> CREATE INDEX test_idx
2 ON address (address1_text)
3 INDEXTYPE IS CTXSYS.CONTEXT
4 FILTER BY postal_code
5 /
Index created.
SCOTT@orcl12c> SET AUTOTRACE ON EXPLAIN
SCOTT@orcl12c> SELECT * FROM address
2 WHERE CONTAINS
3 (address1_text,
4 '"1%" AND "%str%" AND SDATA (postal_code LIKE ''77539%'')') > 0
5 /
ADDRESS1_TEXT POSTAL_CODE
12 astrb 775391
1 row selected.
Execution Plan
Plan hash value: 3864510387
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 44 | 1320 | 13 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| ADDRESS | 44 | 1320 | 13 (0)| 00:00:01 |
|* 2 | DOMAIN INDEX | TEST_IDX | | | 4 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("CTXSYS"."CONTAINS"("ADDRESS1_TEXT",'"1%" AND "%str%" AND SDATA
(postal_code LIKE ''77539%'')')>0)
Note
- dynamic statistics used: dynamic sampling (level=2)
SCOTT@orcl12c> -
Hello
Tried the Oracle White Paper - Oracle Text Web Applications
Created the table and populated with relevant url links
create table htmldb_documentation(
id number,
doc_title varchar2(4000),
doc_url varchar2(4000))
then created the index
create index htmldb_doc_ctxidx on htmldb_documentation(doc_url)
indextype is ctxsys.context
parameters ('datastore CTXSYS.URL_DATASTORE')
Then ran my SQL for the report in Toad and APEX SQL Workshop>SQL Commands before creating an APEX Region based on a SQL Report
select score(1) relevance, doc_title, doc_url
from htmldb_documentation
where CONTAINS (doc_url, :P1_SEARCH, 1) > 0
order by 1 desc
After running the APEX Report I get error
report error:
ORA-29902: error in executing ODCIIndexStart() routine
ORA-20000: Oracle Text error:
DRG-50901: text query parser syntax error on line 1, column 1
I also ran these grant commands after I received this error
grant ctxapp to demo;
grant execute on ctx_cls to demo;
grant execute on ctx_ddl to demo;
grant execute on ctx_doc to demo;
grant execute on ctx_output to demo;
grant execute on ctx_query to demo;
grant execute on ctx_report to demo;
grant execute on ctx_thes to demo;
grant execute on ctx_ulexer to demo;
Any ideas ?? I'm running APEX 3.1.0.00.32 on Oracle 10.2.0.1 on WindowsXP
If I replace the bind variable :P1_SEARCH, with a literal value the error disappearsCouple of things to check:
1) do you have an item called P1_SEARCH in your application?
2) If so, make sure that it has a value; otherwise, Oracle Text gets confused and will throw that error.
You may want to consider using a PL/SQL Function Returning SQL Query that will only append the CONTAINS clause if P1_SEARCH has some value.
Thanks,
- Scott -
http://sumnertechnologies.com
http://spendolini.blogspot.com -
Is anyone familiar with this error. I have removed all the problem characters and words that may cause problems so it is not that.
[1]: (Error): ORA-20000: Oracle Text error: DRG-50901: text query parser syntax error on line 1, column 1 ORA-06512: at line 3
BEGIN
for rec in (select COMMENTS,FAILURE_REASON from COMMENTS7105) loop
update COMMENTS7105
set "CATEGORY" = CASE
when rec.FAILURE_REASON not in (select distinct tmocategory from categories)
then (select "CATEGORY" from (select "CATEGORY",SCORE(1) SCORE from CATEGORIES where contains(SUBCATEGORY, '
<query>
<textquery lang = "ENGLISH" grammar = "CONTEXT">'||rec.comments||'
<progression>
<seq><rewrite>transform((TOKENS, "{", "}", " "))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "NEAR"))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq>
</progression>
</textquery>
<score datatype = "INTEGER" algorithm = "COUNT" />
</query>', 1) <> 0
and SCORE(1) > 1
order by SCORE(1) desc)
where rownum = 1)
when rec.FAILURE_REASON in (select distinct tmocategory from categories)
then (select "CATEGORY" from (select "CATEGORY",SCORE(1) SCORE from CATEGORIES where contains(SUBCATEGORY, '
<query>
<textquery lang = "ENGLISH" grammar = "CONTEXT">'||rec.comments||'
<progression>
<seq><rewrite>transform((TOKENS, "{", "}", " "))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "AND"))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "NEAR"))</rewrite></seq>
<seq><rewrite>transform((TOKENS, "{", "}", "ACCUM"))</rewrite></seq>
</progression>
</textquery>
<score datatype = "INTEGER" algorithm = "COUNT" />
</query>', 1) <> 0
and SCORE(1) > 1
and TMOCATEGORY = rec.FAILURE_REASON
order by SCORE(1) desc)
where rownum = 1)
else 'Unknown' end
where COMMENTS LIKE '%'||rec.COMMENTS||'%';
end loop;
END;
Can someone please help me. Any help is greatly appreciated.Duplicate post answered on Text forum:
Categorizing Data with Oracle Text -
Oracle Text omitting the words as, is, do, or etc in searches
I am trying to do a search using Oracle Text for the country code for Dominican Republic and I get no hits back. This is also the case for some other countries: IS (Iceland), NO (Norway), IT (Italy). Here is my where clause:
where contains(tablename, 'DO within country')
Is there any workaround for this?Those words are stopwords, words that Oracle does not tokenize and index and are not searchable. If you do not specify a stoplist, then Oracle uses the default stoplist, that contains these words. If you use an empty stoplist or a stoplist that does not contain those words, then they are tokenized, inexed, and searchable. Please see the demonstration below that first recreates your situation, or something similar since I don't know what sort of section group you are using, then drops the index and recreates it using an empty stoplist, then shows that DO is tokenized, indexed, and searchable.
SCOTT@10gXE> CREATE TABLE your_table
2 (address VARCHAR2 (30),
3 country VARCHAR2 (2),
4 tablename VARCHAR2 (30))
5 /
Table created.
SCOTT@10gXE> INSERT INTO your_table VALUES ('somewhere', 'DO', NULL)
2 /
1 row created.
SCOTT@10gXE> EXEC CTX_DDL.CREATE_PREFERENCE ('my_multi', 'MULTI_COLUMN_DATASTORE')
PL/SQL procedure successfully completed.
SCOTT@10gXE> EXEC CTX_DDL.SET_ATTRIBUTE ('my_multi', 'COLUMNS', 'address, country')
PL/SQL procedure successfully completed.
SCOTT@10gXE> EXEC CTX_DDL.CREATE_SECTION_GROUP ('my_section_group', 'BASIC_SECTION_GROUP')
PL/SQL procedure successfully completed.
SCOTT@10gXE> EXEC CTX_DDL.ADD_FIELD_SECTION ('my_section_group', 'country', 'country')
PL/SQL procedure successfully completed.
SCOTT@10gXE> CREATE INDEX your_index ON your_table (tablename)
2 INDEXTYPE IS CTXSYS.CONTEXT
3 PARAMETERS
4 ('DATASTORE my_multi
5 SECTION GROUP my_section_group')
6 /
Index created.
SCOTT@10gXE> SELECT token_text FROM dr$your_index$i
2 /
TOKEN_TEXT
SOMEWHERE
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (tablename, 'DO WITHIN country') > 0
3 /
no rows selected
SCOTT@10gXE> DROP INDEX your_index
2 /
Index dropped.
SCOTT@10gXE> CREATE INDEX your_index ON your_table (tablename)
2 INDEXTYPE IS CTXSYS.CONTEXT
3 PARAMETERS
4 ('DATASTORE my_multi
5 SECTION GROUP my_section_group
6 STOPLIST CTXSYS.EMPTY_STOPLIST')
7 /
Index created.
SCOTT@10gXE> SELECT token_text FROM dr$your_index$i
2 /
TOKEN_TEXT
DO
SOMEWHERE
SCOTT@10gXE> SELECT * FROM your_table
2 WHERE CONTAINS (tablename, 'DO WITHIN country') > 0
3 /
ADDRESS CO TABLENAME
somewhere DO
SCOTT@10gXE> -
Can someone post a quick example of an Oracle Text query?
Ben,
Thanks for the quick answer! I was teaching an APEX class and encouraging them to use the forum. I said "I bet someone answers this in an hour or less". You did it in 13 minutes! I tried to ask a question that didn't require any research, so I hope you didn't invest much time in it.
Thanks again,
Tyler
Tyler Muth
http://tylermuth.wordpress.com
"Applied Oracle Security: Developing Secure Database and Middleware Environments": http://sn.im/aos.book -
Oracle companion cd themes for oracle text
Hi i want to install oracle cd companion, but i have not understood what i have to download to run it.
I need use themes for oracle text query's,and oracle 10g xe don't support themes.
Is there a simply procedure that i can follow to install companion correctly?
I have windows xp and oracle 10g.
Important file is droldus.dat..
Thank you very much!!!I have to install companion cd only for testing oracle text's themes on my computer..
and nothing else...
but which are applications that i have installed??
html db??oracle workflow server??i can't understand!!!Are useful in my case, or i must install it? -
Problem to compile sample code with C++ Parser on Unix
I just downloaded C++ parser and tried to compile the sample source code, but I got
the following error:
g++ -o DOMSample -I../include DOMSample.cpp -L../lib/xml8 -L../lib/core8 -L../lib/nls8 -L../lib/xmlc8 -L../lib/nsl -L../lib/socket
Undefined first referenced
symbol in file
Node::getFirstChild(void) /var/tmp/ccarlA8y.o
Node::getValue(void) /var/tmp/ccarlA8y.o
XMLParser::xmlterm(void) /var/tmp/ccarlA8y.o
XMLParser::getDocumentElement(void) /var/tmp/ccarlA8y.o
xmlinit__9XMLParserPUcPFPvPCUcUi_vPvP8xmlsaxcbT3T1 /var/tmp/ccarlA8y.o
Node::hasChildNodes(void) /var/tmp/ccarlA8y.o
Node::getChildNode(unsigned int) /var/tmp/ccarlA8y.o
Node::getName(void) /var/tmp/ccarlA8y.o
Node::numChildNodes(void) /var/tmp/ccarlA8y.o
XMLParser::xmlparse(unsigned char *, unsigned char *, unsigned int)/var/tmp/ccarlA8y.o
Node::getType(void) /var/tmp/ccarlA8y.o
ld: fatal: Symbol referencing errors. No output written to DOMSample
collect2: ld returned 1 exit status
make: *** [DOMSample] Error 1
Please help me out. Thanks,
nullI have the similar problem when I tried to compile sample code with C++ parser on WinNT4. I am using Micrsoft Visual Studio V6.0. I added the include file and lib file in the path.
Here are the error messages:
Linking...
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall XMLParser::xmlterm(void)" (?xmlterm@XMLParser@@QAEXXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class NamedNodeMap * __thiscall DocumentType::getEntities(void)" (?getEntities@DocumentType@@QAEPAVNamedNodeMap@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall NamedNodeMap::item(unsigned int)" (?item@NamedNodeMap@@QAEPAVNode@@I@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall NamedNodeMap::getLength(void)" (?getLength@NamedNodeMap@@QAEIXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class NamedNodeMap * __thiscall DocumentType::getNotations(void)" (?getNotations@DocumentType@@QAEPAVNamedNodeMap@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class DocumentType * __thiscall XMLParser::getDocType(void)" (?getDocType@XMLParser@@QAEPAVDocumentType@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall XMLParser::xmlparse(unsigned char *,unsigned char *,unsigned int)" (?xmlparse@XMLParser@@QAEIPAE0I@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall XMLParser::xmlclean(void)" (?xmlclean@XMLParser@@QAEXXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall CharacterData::replaceData(unsigned long,unsigned long,unsigned char *)" (?replaceData@CharacterData@@QAEXKKPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall CharacterData::deleteData(unsigned long,unsigned long)" (?deleteData@CharacterData@@QAEXKK@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall CharacterData::insertData(unsigned long,unsigned char *)" (?insertData@CharacterData@@QAEXKPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall CharacterData::appendData(unsigned char *)" (?appendData@CharacterData@@QAEXPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall CharacterData::substringData(unsigned long,unsigned long)" (?substringData@CharacterData@@QAEPAEKK@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall CharacterData::getLength(void)" (?getLength@CharacterData@@QAEIXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall CharacterData::setData(unsigned char *)" (?setData@CharacterData@@QAEXPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall CharacterData::getData(void)" (?getData@CharacterData@@QAEPAEXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Text::splitText(unsigned long)" (?splitText@Text@@QAEPAVNode@@K@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::cloneNode(int)" (?cloneNode@Node@@QAEPAV1@H@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall NamedNodeMap::removeNamedItem(unsigned char *)" (?removeNamedItem@NamedNodeMap@@QAEPAVNode@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: int __thiscall NamedNodeMap::setNamedItem(class Node *,class Node * *)" (?setNamedItem@NamedNodeMap@@QAEHPAVNode@@PAPAV2@@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class NamedNodeMap * __thiscall Node::getAttributes(void)" (?getAttributes@Node@@QAEPAVNamedNodeMap@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Attr * __thiscall Element::removeAttributeNode(class Attr *)" (?removeAttributeNode@Element@@QAEPAVAttr@@PAV2@@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Attr * __thiscall Element::setAttribute(unsigned char *,unsigned char *)" (?setAttribute@Element@@QAEPAVAttr@@PAE0@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall Element::removeAttribute(unsigned char *)" (?removeAttribute@Element@@QAEXPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Attr * __thiscall Element::getAttributeNode(unsigned char *)" (?getAttributeNode@Element@@QAEPAVAttr@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall Attr::setValue(unsigned char *)" (?setValue@Attr@@QAEXPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: int __thiscall Element::setAttributeNode(class Attr *,class Attr * *)" (?setAttributeNode@Element@@QAEHPAVAttr@@PAPAV2@@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Attr * __thiscall Document::createAttribute(unsigned char *,unsigned char *)" (?createAttribute@Document@@QAEPAVAttr@@PAE0@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class DocumentFragment * __thiscall Document::createDocumentFragment(void)" (?createDocumentFragment@Document@@QAEPAVDocumentFragment@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall Element::normalize(void)" (?normalize@Element@@QAEXXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::removeChild(void)" (?removeChild@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::replaceChild(class Node *)" (?replaceChild@Node@@QAEPAV1@PAV1@@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Document * __thiscall Node::getOwnerDocument(void)" (?getOwnerDocument@Node@@QAEPAVDocument@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::getParentNode(void)" (?getParentNode@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall NodeList::item(unsigned int)" (?item@NodeList@@QAEPAVNode@@I@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall NodeList::getLength(void)" (?getLength@NodeList@@QAEIXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class NodeList * __thiscall Document::getElementsByTagName(class Element *,unsigned char *)" (?getElementsByTagName@Document@@QAEPAVNodeList@@PAVElement@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: void __thiscall Node::setValue(unsigned char *)" (?setValue@Node@@QAEXPAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::getPreviousSibling(void)" (?getPreviousSibling@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::getLastChild(void)" (?getLastChild@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::getNextSibling(void)" (?getNextSibling@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::getFirstChild(void)" (?getFirstChild@Node@@QAEPAV1@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::insertBefore(class Node *,class Node *)" (?insertBefore@Node@@QAEPAV1@PAV1@0@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class EntityReference * __thiscall Document::createEntityReference(unsigned char *)" (?createEntityReference@Document@@QAEPAVEntityReference@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class CDATASection * __thiscall Document::createCDATASection(unsigned char *)" (?createCDATASection@Document@@QAEPAVCDATASection@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class ProcessingInstruction * __thiscall Document::createProcessingInstruction(unsigned char *,unsigned char *)" (?createProcessingInstruction@Document@@QAEPAVProcessingInstruction@@PA
E0@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Comment * __thiscall Document::createComment(unsigned char *)" (?createComment@Document@@QAEPAVComment@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Text * __thiscall Document::createTextNode(unsigned char *)" (?createTextNode@Document@@QAEPAVText@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Element * __thiscall XMLParser::getDocumentElement(void)" (?getDocumentElement@XMLParser@@QAEPAVElement@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Node * __thiscall Node::appendChild(class Node *)" (?appendChild@Node@@QAEPAV1@PAV1@@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Element * __thiscall Document::createElement(unsigned char *)" (?createElement@Document@@QAEPAVElement@@PAE@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Document * __thiscall XMLParser::getDocument(void)" (?getDocument@XMLParser@@QAEPAVDocument@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class Document * __thiscall XMLParser::createDocument(void)" (?createDocument@XMLParser@@QAEPAVDocument@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall XMLParser::xmlinit(unsigned char *,void (__cdecl*)(void *,unsigned char const *,unsigned int),void *,struct xmlsaxcb *,void *,unsigned char *)" (?xmlinit@XMLPar
ser@@QAEIPAEP6AXPAXPBEI@Z1PAUxmlsaxcb@@10@Z)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall Node::numChildNodes(void)" (?numChildNodes@Node@@QAEIXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: class NodeList * __thiscall Node::getChildNodes(void)" (?getChildNodes@Node@@QAEPAVNodeList@@XZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: int __thiscall Node::hasChildNodes(void)" (?hasChildNodes@Node@@QAEHXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall Attr::getValue(void)" (?getValue@Attr@@QAEPAEXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: int __thiscall Attr::getSpecified(void)" (?getSpecified@Attr@@QAEHXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall Attr::getName(void)" (?getName@Attr@@QAEPAEXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall Node::getValue(void)" (?getValue@Node@@QAEPAEXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: unsigned char * __thiscall Node::getName(void)" (?getName@Node@@QAEPAEXZ)
FullDOM.obj : error LNK2001: unresolved external symbol "public: short __thiscall Node::getType(void)" (?getType@Node@@QAEFXZ)
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/orafulldom.exe : fatal error LNK1120: 64 unresolved externals
Error executing link.exe.
orafulldom.exe - 65 error(s), 0 warning(s)
null
Maybe you are looking for
-
Unable to view photos in iPhoto unless same day import
I imported and edited a bunch of photos in iPhoto yesterday, but when I went to use them today, all I see are blank thumbnails. When I click on these, there's no picture. I can only see the photos I imported today. Where did all my other photos go? A
-
"video signal storage and proccesing​"
Dear Sir, I want to connect a ccd camera to my pc.then I want to display film from ccd on monitor(by labview). I want this control on my film: -brightness -save frame on harddisk -rotate the film or frame can I use of labview? If I can,please help me
-
This error keeps popping up when logging in !
An Unexpected Error has occurred.Your request failed. Please contact your system administrator and provide the date (7/5/15) and time (around 6:00) you received the error and this Exception ID: 14F24E2F.
-
How to save and print PDFs?
For some reason, I am no longer able to save or print PDFs that I download from the internet. This problem developed in the past 2 days, and I never had this problem before. I am able to see the PDF when I download it, but when I go to the saved fi
-
Hello, I just recently purchased the WRVS4400N router and was successful setting it up reconfiguring the right IP address. Suddenly, I tried to log on and I couldn't. Using the Gateway I was currently using. The router login page continuously timed o