Attn Tom Van Lint - re Context Search
For some reason I cannot post a response to the earlier thread
Anyway here's the solution I have. It uses the freeform SQL to provide a text search on the document attribute
// $Header$
// Copyright (c) 2000 Oracle Corporation
package ifs.pm.examples.search;
import ifs.pm.common.application.*;
import oracle.ifs.beans.LibrarySession;
import oracle.ifs.beans.PublicObject;
import oracle.ifs.beans.Document;
import oracle.ifs.beans.ContentObject;
import oracle.ifs.common.IfsException;
import oracle.ifs.beans.Search;
import oracle.ifs.beans.SearchResultObject;
import java.io.BufferedReader;
import java.io.IOException;
import oracle.ifs.search.*;
* A Class class.
* <P>
* @author Mark D. Drake
* Please complete these missing tags
* @rref
* @copyright
* @concurrency
* @see
public class ExtendedContentSearch extends BaseTestHarness
* Constructor
* Please complete the missing tags for ContentSearch
* @param
* @return
* @throws
* @pre
* @post
public ExtendedContentSearch()
* Please complete the missing tags for doSomething
* @param
* @return
* @throws
* @pre
* @post
public void doSomething( LibrarySession ifs )
throws IfsException
ifs.setAdministrationMode(true);
SearchSpecification searchSpecification = buildSearch( Document.CLASS_NAME, "doc", "zydeco" );
Search search = new Search( ifs, searchSpecification );
search.open();
SearchResultObject [] results = search.getItems();
search.close();
if( results != null )
System.out.println("The number of object found is " + results.length);
for( int i = 0; i < results.length; i++ )
SearchResultObject sro = results [ i ];
Document doc = ( Document ) sro.getLibraryObject( Document.CLASS_NAME );
System.out.println( "Document : " + doc.getName() + " Score (query1) = " + sro.getScore("query1"));
doc.filterContent( false );
BufferedReader reader = new BufferedReader( doc.getFilteredContent() );
try
for( String nextLine = reader.readLine();
nextLine != null;
nextLine = reader.readLine() )
System.out.println( nextLine );
catch( IOException ioe )
throw new IfsException( 9999, ioe );
else
System.out.println("No Results Found");
* Please complete the missing tags for buildSearch
* @param
* @return
* @throws
* @pre
* @post
public SearchSpecification buildSearch( String className, String fileExtension, String phrase )
throws IfsException
// Document.DescriptionAttribute contains 'phrase';
AttributeQualification aq1 = new AttributeQualification();
aq1.setAttribute( Document.CLASS_NAME, PublicObject.NAME_ATTRIBUTE );
aq1.setOperatorType( AttributeQualification.LIKE );
aq1.setCaseIgnored( true );
aq1.setValue( "%doc" );
// Document.ContentObject = ContentObject.ID
JoinQualification jq1 = new JoinQualification();
jq1.setLeftAttribute( className, Document.CONTENTOBJECT_ATTRIBUTE );
jq1.setRightAttribute( ContentObject.CLASS_NAME, null );
// Combine the Attribute and Join Qualifications
SearchClause searchClause = new SearchClause( aq1, jq1, SearchClause.AND );
// Create the Content Query 'Document Body contains phrase...' and add it in.
String queryName = "query1";
ContextQualification contentClause = new ContextQualification();
contentClause.setQuery( phrase );
contentClause.setName( queryName );
searchClause = new SearchClause( searchClause, contentClause, SearchClause.AND );
// Add in the FreeForm Search....
FreeFormQualification fq1 = new FreeFormQualification();
fq1.setSqlExpression("contains(description,'Temporary',2) > 0");
searchClause = new SearchClause( searchClause, fq1, SearchClause.AND);
// Set up the Search Class Spec.
SearchClassSpecification scs = new SearchClassSpecification();
// Add in the Class for the Where Clause
String [] searchClasses = new String []
className,
ContentObject.CLASS_NAME
scs.addSearchClasses( searchClasses );
// Add in the Class for the Select Clause
scs.add ResultClass( className );
// Define the Order by Clause
// The List of Classes for the Order Clause
String [] classNames = new String []
ContentObject.CLASS_NAME
// The List of Attibutes for the Order Clause.
String [] attributes = new String []
ContextQualification.ORDER_PREFIX + "." + queryName
// The Ordering for the Attributes in the Order Clause
boolean [] sortOrder = new boolean []
false
SearchSortSpecification sss = new SearchSortSpecification( classNames, attributes, sortOrder );
// AttributeSearchSpecification searchSpec = new AttributeSearchSpecification();
ContextSearchSpecification searchSpec = new ContextSearchSpecification();
searchSpec.setContextClassname( ContentObject.CLASS_NAME );
// Set the SELECT statement and FROM statement of the search
searchSpec.setSearchClassSpecification( scs );
// Set the WHERE clause of the Search
searchSpec.setSearchQualification( searchClause );
// Set the ORDER by clause of the search
searchSpec.setSearchSortSpecification( sss );
return searchSpec;
* main
* @param args
* Please complete the missing tags for main
* @return
* @throws
* @pre
* @post
public static void main( String [] args )
ExtendedContentSearch contentSearch = new ExtendedContentSearch();
contentSearch.run();
It also shows how to get the score for the search on the the document content. I'm still trying to see i can get the score for the description search....
Let me know if this helps
Hello,
I'm working on the similar requirement. same bursting the program based on the TRX_NUMBER. Does the bursting happens?
Thanks
Geetha
Similar Messages
-
Problem with context search in iFS
Hello , here is my problem with iFS.
We have installation of Oracle 8.1.7 Enterprise edition with interMedia and iFS 1.1 on same server (Windows NT Server 4.0/512 RAM). During install everything went fine.
I had uploaded about 200 MB files in the iFS (pdf's and html's).
The problem is when I try to use context based search. If I search for file's name everything is fine, but when I search for a word that is in a file it almost immediately gives mi "0 file(s) found", and I'm sure that there are files that have that word in their body's.
What can be the problem?
Any sugestions will be in help.
Thanks in advance.<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by mark_d_Drake ():
That's the way it works. Content Indexing is not on insert, it occurs when the ctxsrv process runs. See the IntermediaText doc for more information.
<HR></BLOCKQUOTE>
Documents's content is stored in the GLOBALINDEXEDBLOB column of the IFSSYS.ODMM_CONTENTSTORE table.
There is an text index GLOBALINDEXEDBLOB_I built on this column.
To make the context search possible just update this index using the following command in SQL*Plus:
SQL> exec ctx_ddl.sync_index('GLOBALINDEXEDBLOB_I');
If you want this index be updated automatically when new documents are uploaded/changed/deleted in iFS then start the ctxsrv utility on the computer where your Oracle database resides. To do this issue the following command in OS command line:
ctxsrv -user ctxsys/ctxpwd@db_alias
just replace here ctxpwd and db_alias with real values you specified during the installation.
null -
Context search in compressed files
Is there any way of searching for content in compressed files?
For example: if I have five text files in a zip file (and this zip is in iFS), iFS is able to make a context search inside those text files? In our application, the context search works great, but we faced this problem with the zip's.
Thanks in advance,
Fabio.Hi ,
We too have the same problem apart from peformance problem.Looks like iFS API's need lot of improvements. -
Using Context searches in Discoverer
Is there a way to use context searches in Discoverer? Any documentation?
Thanks!Hi there,
I have been developing Discoverer reports (using Customer Folders) where the data is retrieved from apps views (rather than from tables) but I am fairly new to Oracle Apps. I acknowledge (including the previous post) that the Apps views include the PL/SQL code to perform the Org Id checking.
I believe that the Organization Id is derived from the 'Responsibility', hence only the related data is retrieved. Therefore, I have not included any special code to check for Organization-specific data.
Can anyone tell me whether this assumption is correct? More importantly, how/where does the Responsibility define the Organisation or set the 'Client_info'?
In SQL*Plus or TOAD, I would run the following script to set the client_info before any data can be retrieved. My Org Id is 83.
begin
dbms_application_info.set_client_info('83');
end
Thanks, looking forward to an answer.
Regards,
John -
ConText Search Option - Need Help
Hi,
I am wondering if the freely available oracle s/w supports ConText search option. I am getting error notice when i tried to configure context search option by ctxctl command.
Please suggest me what to do to invoke conText search option.
Thanks,
RajeshIt would be a stand alone program, when you enter a url into the input box and hit search it should load the url typed in , in frame 2. But if the "Use Proxy" check box is checked then it should include the proxy in each search.
This swf is pretty self explanitory - http://www.mediafire.com/?6e9kl90s23lcyb9 -
Context search on content + other field(s)
I'm using oracle.ifs.search.* classes to do a context search on the content but at the same time I want to do a context search on the DOCUMENT.DESCRIPTION field.
(A bit like what you can do when searching in this Forum)
The ContextSearchSpecification only seems to allow 1 classname for the context Query.
I could use a FreeFormQualification instead, I guess, but then I'm not only loosing late binding, but I cannot get to the score results and nor can I sort on the scores.
Are there ways to overcome this ?
Are there any examples on how to use a FreeFormQualification exactly ?
nullAnother method that puzzles me a lot :
oracle.ifs.search.ContextSearchSpecification.setMedia(oracle.ifs.beans.Media [] media)
It is supposed to explicitly set the Media to search over. Can I use it to do a context search on multiple media ? It looks that way.
oracle.ifs.beans.Media is not documented.
Any examples of the use of setMedia ? -
Context search defaults to local country
Select part of a web page, right click it and "search Google for ....." appears.
This feature works perfectly when I am in the UK, but I travel and currently it searches Thailand version of Google - I want it to search the UK version of Google.
Is there any way to force Firefox to search Google.co.uk and not Google.com?
Using Windows XP - Firefox 8.0.1The browser.search.selectedEngine pref determines which of the installed search engines to use for context search if it exists.<br />
Otherwise the default search engine as specified in browser.search.defaultenginename is used.<br />
If you do not have the browser.search.selectedEngine pref then you can create a new String pref with the name browser.search.selectedEngine and set the name to the preferred search engine.<br />
I see a browser.search.selectedEngine pref if I select a search engine that is different from the default search engine.
Do you have a Google.co.uk ((Google UK) search engine installed?
You can find search engines on the Mycroft Project website.
* http://mycroft.mozdev.org/
* http://mycroft.mozdev.org/google-search-plugins.html -
Context search timeout not considered ?
Consider the following method that query twice a LDAP directory and hangs in the second query for nearly 10 minutes - I think that is TCP timeout - in the context search even if set a timeout of 5 seconds.
The connection has been closed between the first and the second search by a firewall, dueto the "Stateful inspection policy".
Have I forgotten some thing ? Or is the LDAP SPI that has a bug ?
This is the code, hope you've some advice...
Thank you
Roberto
public class MyLdap {
private LdapContext lDapCtx;
// some other declarations
public MyLdap() {}
private LdapContext createLdapContext() {
this.ldapEnv.put("java.naming.factory.initial",
"com.sun.jndi.ldap.LdapCtxFactory");
this.ldapEnv.put("java.naming.factory.url.pkgs", "com.sun.jndi.ldap");
this.ldapEnv.put("java.naming.provider.url", HOST_NAME);
this.ldapEnv.put("com.sun.jndi.ldap.connect.timeout","500");
try {
logger.fine("Creating LdapContext");
this.lDapCtx = new NGTInitialLdapContext(ldapEnv, null);
return this.lDapCtx;
catch (NamingException ex) {
this.lDapCtx = null;
logger.severe("Failed creating LdapContext");
logger.stack(ex);
return this.lDapCtx;
public NamingEnumeration search(String baseSearchStr, String filter, SearchControls constraints) throws NamingException {
NamingEnumeration results = null;
int timeout = 1000;
// timeout set constraints.setTimeLimit(timeout);
//Try search
long ini = System.currentTimeMillis();
System.out.println("Before ctx.search");
try {
results = ctx.search(baseSearchStr, filter, constraints);
System.out.println("After ctx.search secs: " + ((System.currentTimeMillis()-ini)/1000));
return results;
catch (CommunicationException e) {
System.out.println("Catch CommunicationException");
//Communication failure try ricreate context
this.recreateInitialLdapContext();
results = ctx.search(baseSearchStr, filter, constraints);
return results;
catch (NameNotFoundException ex) {
//e' un name not found, sollevo l'eccezione
System.out.println("Catch di NameNotFoundException");
throw ex;
catch (NamingException ne) {
//Tento cmq di ricostruire il contesto
System.out.println("Catch di NamingException");
this.recreateInitialLdapContext();
results = ctx.search(baseSearchStr, filter, constraints);
return results;
private void recreateInitialLdapContext() throws NamingException {
synchronized (ctx) {
System.out.println("First close context, then try recreating context");
ctx.close();
System.out.println("Context closed");
long ini = System.currentTimeMillis();
System.out.println(
"Prima di new InitialLdapContext(environment, connCtls)");
ctx = new InitialLdapContext(environment, connCtls);
System.out.println(
"Dopo di new InitialLdapContext(environment, connCtls), secondi: " +
( (System.currentTimeMillis() - ini) / 1000));
System.out.println("Succeed recreating context");
private static void search() throws Exception {
try {
logger.info("\nSearching ********************************************");
String baseSearchStr = "uid=smith, ou=UP , o=myorg";
// set the search filter in uid matching
String filter = ("uid=*");
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.OBJECT_SCOPE);
NamingEnumeration results = lDapCtx.search(baseSearchStr, filter, constraints);
while (results.hasMore()) {
SearchResult sr = (SearchResult) results.next();
Attributes att = sr.getAttributes();
NamingEnumeration idEn = att.getIDs();
while (idEn.hasMore()) {
String id = (String) idEn.next();
Attribute attrib = att.get(id);
logger.info( (String) attrib.get());
logger.info("Searching done****************************************");
catch (NamingException ex) {
logger.info("search failed");
throw ex;
private static void waitFor(int delay) {
logger.info("\nWaiting "+ delay + " seconds ****************************************");
long ini, temp;
int divisor = new Integer(1000).intValue();
ini = System.currentTimeMillis();
while ( true ) {
temp = System.currentTimeMillis() - ini;
if ( ((int) temp/divisor) == delay) {
break;
logger.info("Waiting done****************************************");
public static void main(String[] args) {
ldap ldap1 = new ldap();
try {
createLdapCtx();
search();
waitFor(new Integer(args[0]).intValue());
search();
lDapCtx.close();
catch (Exception ex) {
ex.printStackTrace();Sorry, the line:
this.lDapCtx = new NGTInitialLdapContext(ldapEnv, null);
instantiate the class NGTInitialLdapContext and in the constructor there is the following line:
ctx = new InitialLdapContext(environment, connCtls);
Roberto -
Context search in iFS/Linu
Hello,
my question is about the INSO_FILTER that is used when binary files are indexed(pdf, doc,..). In the IFS context search is about that, and there is IFS for Linux, that means that there is some kind of filter for Linux. Can that filter be used to index documents with Oracle text under Linux?
Thanks<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by mark_d_Drake ():
That's the way it works. Content Indexing is not on insert, it occurs when the ctxsrv process runs. See the IntermediaText doc for more information.
<HR></BLOCKQUOTE>
Documents's content is stored in the GLOBALINDEXEDBLOB column of the IFSSYS.ODMM_CONTENTSTORE table.
There is an text index GLOBALINDEXEDBLOB_I built on this column.
To make the context search possible just update this index using the following command in SQL*Plus:
SQL> exec ctx_ddl.sync_index('GLOBALINDEXEDBLOB_I');
If you want this index be updated automatically when new documents are uploaded/changed/deleted in iFS then start the ctxsrv utility on the computer where your Oracle database resides. To do this issue the following command in OS command line:
ctxsrv -user ctxsys/ctxpwd@db_alias
just replace here ctxpwd and db_alias with real values you specified during the installation.
null -
Oracle text performance with context search indexes
Search performance using context index.
We are intending to move our search engine to a new one based on Oracle Text, but we are meeting some
bad performance issues when using search.
Our application allows the user to search stored documents by name, object identifier and annotations(formerly set on objects).
For example, suppose I want to find a document named ImportSax2.c: according to user set parameters, our search engine format the following
search queries :
1) If the user explicitely ask for a search by document name, the query is the following one =>
select objid FROM ADSOBJ WHERE CONTAINS( OBJFIELDURL , 'ImportSax2.c WITHIN objname' , 1 ) > 0;
2) If the user don't specify any extra parameters, the query is the following one =>
select objid FROM ADSOBJ WHERE CONTAINS( OBJFIELDURL , 'ImportSax2.c' , 1 ) > 0;
Oracle text only need around 7 seconds to answer the second query, whereas it need around 50 seconds to give an answer for the first query.
Here is a part of the sql script used for creating the Oracle Text index on the column OBJFIELDURL
(this column stores a path to an xml file containing properties that have to be indexed for each object) :
begin
Ctx_Ddl.Create_Preference('wildcard_pref', 'BASIC_WORDLIST');
ctx_ddl.set_attribute('wildcard_pref', 'wildcard_maxterms', 200) ;
ctx_ddl.set_attribute('wildcard_pref','prefix_min_length',3);
ctx_ddl.set_attribute('wildcard_pref','prefix_max_length',6);
ctx_ddl.set_attribute('wildcard_pref','STEMMER','AUTO');
ctx_ddl.set_attribute('wildcard_pref','fuzzy_match','AUTO');
ctx_ddl.set_attribute('wildcard_pref','prefix_index','TRUE');
ctx_ddl.set_attribute('wildcard_pref','substring_index','TRUE');
end;
begin
ctx_ddl.create_preference('doc_lexer_perigee', 'BASIC_LEXER');
ctx_ddl.set_attribute('doc_lexer_perigee', 'printjoins', '_-');
ctx_ddl.set_attribute('doc_lexer_perigee', 'BASE_LETTER', 'YES');
ctx_ddl.set_attribute('doc_lexer_perigee','index_themes','yes');
ctx_ddl.create_preference('english_lexer','basic_lexer');
ctx_ddl.set_attribute('english_lexer','index_themes','yes');
ctx_ddl.set_attribute('english_lexer','theme_language','english');
ctx_ddl.set_attribute('english_lexer', 'printjoins', '_-');
ctx_ddl.set_attribute('english_lexer', 'BASE_LETTER', 'YES');
ctx_ddl.create_preference('german_lexer','basic_lexer');
ctx_ddl.set_attribute('german_lexer','composite','german');
ctx_ddl.set_attribute('german_lexer','alternate_spelling','GERMAN');
ctx_ddl.set_attribute('german_lexer','printjoins', '_-');
ctx_ddl.set_attribute('german_lexer', 'BASE_LETTER', 'YES');
ctx_ddl.set_attribute('german_lexer','NEW_GERMAN_SPELLING','YES');
ctx_ddl.set_attribute('german_lexer','OVERRIDE_BASE_LETTER','TRUE');
ctx_ddl.create_preference('japanese_lexer','JAPANESE_LEXER');
ctx_ddl.create_preference('global_lexer', 'multi_lexer');
ctx_ddl.add_sub_lexer('global_lexer','default','doc_lexer_perigee');
ctx_ddl.add_sub_lexer('global_lexer','german','german_lexer','ger');
ctx_ddl.add_sub_lexer('global_lexer','japanese','japanese_lexer','jpn');
ctx_ddl.add_sub_lexer('global_lexer','english','english_lexer','en');
end;
begin
ctx_ddl.create_section_group('axmlgroup', 'AUTO_SECTION_GROUP');
end;
drop index ADSOBJ_XOBJFIELDURL force;
create index ADSOBJ_XOBJFIELDURL on ADSOBJ(OBJFIELDURL) indextype is ctxsys.context
parameters
('datastore ctxsys.file_datastore
filter ctxsys.inso_filter
sync (on commit)
lexer global_lexer
language column OBJFIELDURLLANG
charset column OBJFIELDURLCHARSET
format column OBJFIELDURLFORMAT
section group axmlgroup
Wordlist wildcard_pref
Oracle created a table named DR$ADSOBJ_XOBJFIELDURL$I which now contains around 25 millions records.
ADSOBJ is the table contaings information for our documents,OBJFIELDURL is the field that contains the path to the xml file containing
data to index. That file looks like this :
<?xml version="1.0" encoding="UTF-8" ?>
<fields>
<OBJNAME><![CDATA[NomLnk_177527o.jpgp]]></OBJNAME>
<OBJREM><![CDATA[Z_CARACT_141]]></OBJREM>
<OBJID>295926o.jpgp</OBJID>
</fields>
Can someone tell me how I can make that kind of request
"select objid FROM ADSOBJ WHERE CONTAINS( OBJFIELDURL , 'ImportSax2.c WITHIN objname' , 1 ) > 0;"
run faster ?Below are the execution plan for both the 2 requests :
select objid FROM ADSOBJ WHERE CONTAINS( OBJFIELDURL , 'ImportSax2.c WITHIN objname' , 1 ) > 0
PLAN_TABLE_OUTPUT
| Id | Operation |Name |Rows |Bytes |Cost (%CPU)|
| 0 | SELECT STATEMENT | |1272 |119K | 4 (0) |
| 1 | TABLE ACCESS BY INDEX ROWID |ADSOBJ |1272 |119K | 4 (0) |
| 2 | DOMAIN INDEX |ADSOBJ_XOBJFIELDURL | | | 4 (0) |
Note
- 'PLAN_TABLE' is old version
Executed in 2 seconds
select objid FROM ADSOBJ WHERE CONTAINS( OBJFIELDURL , 'ImportSax2.c' , 1 ) > 0
PLAN_TABLE_OUTPUT
| Id |Operation |Name |Rows |Bytes |Cost (%CPU)|
| 0 | SELECT STATEMENT | |1272 |119K | 4 (0) |
| 1 | TABLE ACCESS BY INDEX ROWID |ADSOBJ |1272 |119K | 4 (0) |
| 2 | DOMAIN INDEX |ADSOBJ_XOBJFIELDURL | | | 4 (0) |
Sorry for the result formatting, I can't get it "easily" readable :( -
ORDDOC and context searching!!
We have a scenario in which client uploads file in the format doc,ppt,pdf into database and is stored as orddoc format.
The version of database used in 9i. The client has a requirement in which he needs to search for a particular text inside the document.
Q1. Is this possible using the Orddoc dataype and ctxsys
We have tried with CLOB datatype and were able to search for a particular string inside the document.
Which is best datatype for this purpose and does oracle has any other tools/methods by which this can be done?Hi Satish,
I followed the procedure in the link
Created the table
CREATE TABLE SEARCHTABLE
SNO NUMBER NOT NULL,
DATA ORDSYS.ORDDOC
Then created the index as
CREATE INDEX DATA_CTX_IND ON searchTable(data.source.localdata) INDEXTYPE IS CTXSYS.CONTEXT;
Latter i upload a txt file and recreated the index. I checked the DATA_CTX_IND$I table and found that no data was populated.
I run the query
CREATE INDEX DATA_CTX_IND ON searchTable(data.source.localdata) INDEXTYPE IS CTXSYS.CONTEXT;
and i am getting the following
ORA-29900:operator binding does not exist ORA -06553 : PLS-306 : wrong number or types of arguments in call to 'CONTAINS'
The same query worked fine for varchar and clob type field, so how can it suddently fail for orddoc?
Note: I am not an expert in oracle.. i just having working knowledge .. and this is first complex thing i am doing -
We have installed Oracle 8.1.6 Enterprise edition with interMedia and iFS on same server(Solaris).
The problem is when I search for a word that is in a file, I do not get any results. ctxsrv is up .
command to run the program:
java ContentSearch_3 testing
Please see the attached code:
DOCUMENT INSTANCE -- XML
<?xml version="1.0" standalone="yes" ?>
<SimplestType>
<name>fifth.SimplestType</name>
<description>testing testing testing</description>
<simplestValue>The Fifth Simple Value</simplestValue>
</SimplestType>
TYPE DEFINITION FILE
<?xml version="1.0" standalone="yes" ?>
<classobject>
<name>SimplestType</name>
<superclass RefType="name">Document</superclass>
<attributes>
<attribute>
<name>simplestValue</name>
<DataType>String</DataType>
<DataLength>50</DataLength>
</attribute>
</attributes>
</classobject>
CONTENTSEARCH_3 PROGRAM
public class ContentSearch_3
LibrarySession ifsSession;
* Constructor
public ContentSearch_3()
public void run(String searchStr) throws Exception{
System.out.println("Start Method : run");
//Connect to the repository.
LibraryService ifsService = new LibraryService();
CleartextCredential me = new CleartextCredential("username", "password");
ConnectOptions connectOpts= new ConnectOptions();
connectOpts.setServiceName("IfsDefault");
connectOpts.setServicePassword("ifs");
ifsSession = ifsService.connect(me, connectOpts);
doSomething(ifsSession, searchStr);
System.out.println("End Method : run");
public void doSomething(LibrarySession ifs, String searchStr)
throws IfsException
System.out.println("Start Method : doSomething");
SearchSpecification searchSpecification = buildSearch("SIMPLESTTYPE","SimplestType",searchStr);
Search search = new Search(ifs, searchSpecification);
search.open();
SearchResultObject[] results = search.getItems();
search.close();
if (results != null) {
System.out.println("SearchResultObject[] results not null");
for (int i = 0; i < results.length; i++)
SearchResultObject sro = results;
Document doc = (Document) sro.getLibraryObject(Document.CLASS_NAME);
System.out.println("Document : " + doc.getName());
doc.filterContent(false);
BufferedReader reader = new BufferedReader(doc.getFilteredContent());
try {
for (String nextLine = reader.readLine();
nextLine != null;
nextLine = reader.readLine())
System.out.println(nextLine);
} catch (IOException ioe) {
throw new IfsException(9999,ioe);
else
System.out.println("results are null");
System.out.println("End Method : doSomething");
public SearchSpecification buildSearch(String className,String fileExtension,String phrase)
throws IfsException
System.out.println("Start Method : buildSearch");
// Document.NAME like '%doc';
System.out.println("className=" + className + ", fileExtension =" + fileExtension +
", phrase =" + phrase);
AttributeQualification aq1 = new AttributeQualification();
aq1.setAttribute("SIMPLESTTYPE",PublicObject.NAME_ATTRIBUTE);
//aq1.setAttribute(Document.CLASS_NAME,PublicObject.NAME_ATTRIBUTE);
aq1.setOperatorType(AttributeQualification.LIKE);
aq1.setCaseIgnored(true);
aq1.setValue("%SimplestType");
// print aq1 attributes
System.out.println("aq1.getAttributeClass() =" + aq1.getAttributeClass());
System.out.println("aq1.getAttributeClassname() = " +aq1.getAttributeClassname() );
System.out.println(" aq1.getAttributeName()=" +aq1.getAttributeName());
System.out.println("aq1.getClass() = " +aq1.getClass().toString());
System.out.println("aq1.getValue() =" + aq1.getValue());
// Create Folder Restrict option now.
/* FolderRestrictQualification frq = new FolderRes trictQualification();
FolderPathResolver fpr = new FolderPathResolver(ifsSession);
Folder startFolder = (Folder) fpr.findPublicObjectByPath("/home/Sridevi");
frq.setStartFolder(startFolder);
frq.setMaxLevels(1);
// Document.ContentObject = ContentObject.ID
JoinQualification jq1 = new JoinQualification();
jq1.setLeftAttribute(className,Document.CONTENTOBJECT_ATTRIBUTE);
jq1.setRightAttribute(ContentObject.CLASS_NAME,null);
// Combine the Attribute and Join Qualifications
SearchClause searchClause = new SearchClause( aq1, jq1 , SearchClause.AND );
// Create the Content Query
// Text contains phrase...
String queryName = "query1";
ContextQualification contentClause = new ContextQualification();
contentClause.setQuery(phrase);
contentClause.setName(queryName);
// Combine the Relational and Text Qualifications
searchClause = new SearchClause(searchClause,contentClause, SearchClause.AND);
// Set up the Search Class Spec.
SearchClassSpecification scs = new SearchClassSpecification();
// Add in the Class for the Where Clause
String[] searchClasses = new String[] {className,ContentObject.CLASS_NAME};
scs.addSearchClasses(searchClasses);
// Add in the Class for the Select Clause
scs.addResultClass(className);
// Define the Order by Clause
// The List of Classes for the Order Clause
String[] classNames = new String[] {ContentObject.CLASS_NAME};
// The List of Attibutes for the Order Clause.
String[] attributes = new String [] { ContextQualification.ORDER_PREFIX + "." + queryName};
// The Ordering for the Attributes in the Order Clause
boolean[] sortOrder = new boolean[] {false};
SearchSortSpecification sss = new SearchSortSpecification(classNames,attributes,sortOrder);
ContextSearchSpecification searchSpec = new ContextSearchSpecification();
searchSpec.setContextClassname(ContentObject.CLASS_NAME);
// Set the SELECT statement and FROM statement of the search
searchSpec.setSearchClassSpecification(scs);
// Set the WHERE clause of the Search
searchSpec.setSearchQualification(searchClause);
// Set the ORDER by clause of the search
searchSpec.setSearchSortSpecification(sss);
System.out.println("End Method : buildSearch");
return searchSpec;
* main
* @param args
public static void main(String[] args) throws Exception
System.out.println("program start");
ContentSearch_3 contentSearch = new ContentSearch_3();
contentSearch.run(args[0]);
System.out.println("program end");
Any suggestions will be in help.
Thanks.Try to follow the steps Alan suggest in http://technet.oracle.com:89/ubb/Forum36/HTML/001278.html to test if your context install is working.
We need to find out if this is a context problem or an iFS problem first. -
Context search if char [ or ( is typed by mistake - error DRG-50901
If the search string has [ or (, why doesn't context treat it as
a part of the string? Do I have to do anything special to avoid
the run time error -
ORA-20000: interMedia Text error: DRG-50901: text query parser
syntax error on line 1, column 13
Thanks in advance
VidhyaI found this
http://technet.oracle.com/products/text/x/Tech_Overviews/imt_817.
html
But it does not work as I expect
The CTXCAT Query Language
Once the ctxcat index is created, you query using the operator
catsearch
instead of contains:
select item_desc from auction
where catsearch(item_desc, 'oracle', null)>0;
This finds all rows in auction which have "oracle" in the
item_desc text.
Like contains, the first argument is the text column, and the
second is the
query string. The third argument we'll talk about below -- just
ignore it
for now. There is no score label argument, because catsearch
does not
provide scoring -- it is a simple boolean search.
The catsearch operator uses a much simpler query language than
contains,
with the intent that web-style queries can be passed through to
catsearch
without extra parsing. The query language rules are:
* Multiple words are treated as an AND.
* Vertical bar is used for OR.
* A leading plus sign on words is ignored and discarded
* A leading minus sign excludes words (must have included
words)
* Double quotes delimit phrases.
* Parentheses group operations.
Or, in comparison:
catearch Query Equivalent contains query
A B A & B
A | B A | B
+A -B A ~ B
"A B" A B
"A B" C (A B) & C
(A B) | C (A & B) | C
AND, OR, AND-NOT, and PHRASE are the only functions currently
available in the
catsearch query language. catsearch does not support any of the
other
features found in the context query language such as accum,
within, fuzzy,
stem, wildcard, thesaurus, near, etc. -
XML context search with escape characters
Hi,
I have a piece of XML in an XMLTYPE column which is context indexed. The xml looks like
<content>
<EndDate/>
<Councillor>Smith John</Councillor>
<Committee>Inspection Leader&#039;s Advisory Body </Committee>
<StartDate/>
<LinkType>Committee Link</LinkType>
<Text/>
</content>
My query which escapes the search field between {} is
select xmlType.getStringVal(xmlType.extract(CI.CONTENT_XML,'/content/Committee/text()')) Committee
from CMPS.CM$CONTENT_ITEMS CI
where CONTAINS(content_xml,'{Inspection&a} INPATH(/content/Committee)') > 0
returns the row successfully
However
select xmlType.getStringVal(xmlType.extract(CI.CONTENT_XML,'/content/Committee/text()')) Committee
from CMPS.CM$CONTENT_ITEMS CI
where CONTAINS(content_xml,'{Inspection&am} INPATH(/content/Committee)') > 0
--Note the extra character in between {}
does not return anything.
Can someone tell me if I am escaping the reserved characters correctly?
Is there something that I missed when I created my index i.e
CREATE INDEX CIM_CONTEXT ON
cm$content_items(content_xml) indextype is ctxsys.context;
I am running 9.2.0.4 on RED HAT 3.
Thanks
Joel.From the text team...
The default section group for XMLType column is path section group.
As for his question, the reason why he gets a hit for the first query:
{Inspection&a} INPATH(/content/Committee), is because {Inspenction&a} is lexed as
a phrase "Inspection a" and a by default is 'a' stop word.
And {Inspection&am} is lexed as a phrase "Inspection am". Since there is no such phrase ("am" is not a stop word), the query does not return the row.
If he tries {Inspection&an}, he will get the row because "an" is again by default a stop word.
The behavior is independent of INPATH operator. He will see the same behavior without INPATH operator:
select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&a}') > 0;
select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&am}') > 0;
select * from CMPS.CM$CONTENT_ITEMS CI where CONTAINS(content_xml,'{Inspection&an}') > 0;
Note sure I understand it but I hope it helps -
Performance issue with context search
We have a performance problem with a table tise with about 10 mio rows
and a text column tise_desc with short descriptions (about 300 characters per row).
We currently use mixed queries of the form (here very simple)
SELECT /*+ FIRST_ROWS(10) */ * FROM tise
WHERE reg_id = 'REGI0000000000000132'
AND contains(tise_desc, '(employment)' ) > 0
When the structured query part (here reg_id) and the fulltext part (contains) is not selective some queries take about 30 sec to 90 sec to process.
When we repeat the query it only takes about 1-3 sec (may be due to caching).
We are not interested in scoring nor in sorting the data.
Until now we have tried to use different hints, use different index types (btree versus bitmap), use different sql query syntax, use one fulltext index with xml and within syntax without any real progress.
Has any body addtional ideas?Since you are doing a combination of structured queries and simple text queries on only one column, a ctxcat index with a catsearch may be better than a context index with a contains search. The catsearch has fewer additional features available than contains, but some context features can be done with catsearch through a query template. If you only do simple searches and don't need those extra features then it doesn't matter.
Make sure you have current statistics, so that the optimizer can use them to select the best execution plan.
Use bind variables instead of literal values in your searches. When you use bind variables, the previous query in the SGA can be reused for different variable values without reparsing, so that every query with new values has the same effect as rerunning the previous query. This alone could account for the different between 30 to 90 seconds on the first run and 1-3 seconds on the second run.
If you are not using scoring or sorting, then you might be better off without the first_rows hint, which chooses the best path for sorting. Try it both ways and see which works best for you.
Once you have tested with a ctxcat index, current statistics, and bind variables, if it is still slow you may be able to use some tracing to determine the cause of the slowness and adjust some memory settings or some such thing. You can find more tuning hints for Oracle Text here:
http://download.oracle.com/docs/cd/B28359_01/text.111/b28303/aoptim.htm#i1007227
Please see the demonstration below that implements the recommendations above.
SCOTT@orcl_11g> CREATE TABLE tise
2 (reg_id VARCHAR2 (20),
3 tise_desc VARCHAR2 (300))
4 /
Table created.
SCOTT@orcl_11g> INSERT INTO tise VALUES ('REGI0000000000000132', 'employment')
2 /
1 row created.
SCOTT@orcl_11g> INSERT INTO tise SELECT object_id, object_name FROM all_objects
2 /
68770 rows created.
SCOTT@orcl_11g> -- try a ctxcat index instead of a context index
SCOTT@orcl_11g> -- (make sure the index is not fragmented by periodically
SCOTT@orcl_11g> -- dropping and recreating or altering and rebuilding or optimizing)
SCOTT@orcl_11g> BEGIN
2 CTX_DDL.CREATE_INDEX_SET ('tise_iset');
3 CTX_DDL.ADD_INDEX ('tise_iset', 'reg_id');
4 END;
5 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> CREATE INDEX tise_id_desc_idx ON tise (tise_desc)
2 INDEXTYPE IS CTXSYS.CTXCAT
3 PARAMETERS ('INDEX SET tise_iset')
4 /
Index created.
SCOTT@orcl_11g> -- make sure you have current statistics:
SCOTT@orcl_11g> EXEC DBMS_STATS.GATHER_TABLE_STATS (USER, 'TISE')
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> -- use bind variables so that the query in the sga can be reused
SCOTT@orcl_11g> -- for different variable values without reparsing:
SCOTT@orcl_11g> VARIABLE search_reg_id VARCHAR2 (20)
SCOTT@orcl_11g> VARIABLE search_desc VARCHAR2 (2000)
SCOTT@orcl_11g> EXEC :search_reg_id := 'REGI0000000000000132'
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> EXEC :search_desc := 'employment'
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> -- query using catsearch with a ctxcat index and bind variables:
SCOTT@orcl_11g> COLUMN tise_desc FORMAT A30 WORD_WRAPPED
SCOTT@orcl_11g> SET AUTOTRACE ON EXPLAIN
SCOTT@orcl_11g> SELECT *
2 FROM tise
3 WHERE CATSEARCH (tise_desc, :search_desc, 'reg_id=''' || :search_reg_id || '''') > 0
4 /
REG_ID TISE_DESC
REGI0000000000000132 employment
Execution Plan
Plan hash value: 409728589
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3439 | 100K| 102 (0)| 00:00:02 |
| 1 | TABLE ACCESS BY INDEX ROWID| TISE | 3439 | 100K| 102 (0)| 00:00:02 |
|* 2 | DOMAIN INDEX | TISE_ID_DESC_IDX | | | | |
Predicate Information (identified by operation id):
2 - access("CTXSYS"."CATSEARCH"("TISE_DESC",:SEARCH_DESC,'reg_id='''||:SEARCH_REG_ID|
|'''')>0)
SCOTT@orcl_11g> SET AUTOTRACE OFF
SCOTT@orcl_11g>
Maybe you are looking for
-
Unable to install flash player on Windows XP
Unable to install XP using both browsers: IE and firefox. Getting error message: Error: General installation error Removed temporary internet files also. still unable to install.
-
Pages program is frozen. I cannot access my documents. Can somebody help me?
I cannot access my document in the pages program because it is stuck. Can anybody give me any suggestions on what I need to do so that it will respond? Thank you
-
Well one of those days Itunes sent me and up date that just crashed and took out my player can't start it up MSVCR.80 dill missing and now what happens to all my music and store credit and purchase s ???? anyone i'm trying to reload it i hope it do
-
This is all I can remember. The Firefox download process did not complete.
-
Application Error on system run
When I run Windows I get: Application Error CouldNotLoadArgumentException[ Could not load file/URL specified: E:\Documents and Settings\Konrad\Dane aplikacji\Sun\Java\Deployment\cache\6.0\48\103a1530-21f21f05] at com.sun.javaws.Main.launchApp(Un