oracle.ifs.search
Class ContextSearchSpecification
java.lang.Object
|
+--oracle.ifs.search.SearchSpecification
|
+--oracle.ifs.search.AttributeSearchSpecification
|
+--oracle.ifs.search.ContextSearchSpecification
- All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable
- public class ContextSearchSpecification
- extends AttributeSearchSpecification
A ContextSearchSpecification represents a Search on both Attributes and Content.
The SearchQualification (SearchTree) of a ContextSearchSpecification should have at least one
ContextQualification.
The user must also specify the Class on which the ContextQualifications are to be
applied.
The Text Query of each ContextQualification is applied on each Media. The result
will contain entries from all the Media. The Media rows will be joined
with the ContextClass, so that only the Content of objects in the
ContextClass is considered. Otherwise, there is nothing special about what
is returned by a Context Search. For every result row, the conditions defined
by the SearchTree must hold.
// Usage Examples
// How to build a Context Search specification
// Process is very similar to that of building an AttributeSearchSpecification.
// Construct the ContextSearchSpecification.
ContextSearchSpecification csp = new ContextSearchSpecification();
// Let's assume we have the 3 parts needed.
// They are SearchClassSpecification - SELECT list and FROM list
// SearchQualification - WHERE condition
// SearchSortSpecification - ORDER BY clause
SearchClassSpecification someSearchSpec = ...;
SearchSortSpecification someSortSpec = ... ;
SearchQualification someSearchQual = ...;
LibrarySession sess = ...;
// Set the search class spec. Make sure the class
// spec includes the class that stores the content, CONTENTOBJECT
// in most cases.
csp.setSearchClassSpecification(someSearchSpec);
// Set the search qualification. Make sure there is
// at least one ContextQualification in this.
csp.setSearchQualification(someSearchQual);
// Set the sort specification. Specify context
// score based ordering in the sort spec if necessary.
csp.setSearchSortSpecification(someSortSpec);
// One extra step in ContextSearchSpecification is to
// setup the context search class.
csp.setContextClassname(ContentObject.CLASS_NAME);
// Now we are ready to build a Search or create a View.
// Building a search
Search someSearch = new Search(sess, asp);
// Or creating a view. Note that View itself will not have
// content in it.
ViewSpecification viewSpec = new ViewSpecification("TestView", asp);
// ---------------------------------------------------------------
// Complete example of a Search using ContextSearchSpecification
// ---------------------------------------------------------------
// Let's build a search that looks for all DOCUMENTS with a given
// word "FOOBAR" and are named FOO.
// Let's build the WHERE condition first.
// It will be - DOC.Contains(FOOBAR) and DOC.NAME='FOO'
// DOC.Contains = FOO
String contextClauseName = "CQ1";
String queryTerm = "FOOBAR";
ContextQualification cq1 = new ContextQualification();
cq1.setQuery(queryTerm);
cq1.setName(contextClauseName);
// Since content in stored in CONTENTOBJECT, the above
// ContextQualification is actually doing a contains on CONTENETOBJECT.
// Therefore, we need to join the CONTENTOBJECT with DOCUMENT.
// Create a JoinQualification. This sort of join is a must
// for all context searches.
// SQL generated - DOC.CO = CO.ID
JoinQualification jq1 = new JoinQualification();
jq1.setLeftAttribute(Document.CLASS_NAME, Document.CONETNTOBJECT_ATTRIBUTE);
jq1.setRightAttribute(ContentObject.CLASS_NAME, null);
// DOC.NAME= 'FOO'
AttributeQualification aq1 = new AttributeQualification();
aq1.setAttribute(PublicObject.NAME_ATTRIBUTE);
aq1.setOperatorType(AttributeQualification.EQUAL);
aq1.setValue("FOO");
// Put them together with an AND. With that our
// SearchQualification is ready.
// The search tree looks like - cq1 AND aq1 and jq1
SearchClause sc = new SearchClause(cq1, aq1, SearchClause.AND);
sc = new SearchClause(sc, jq1, SearchClause.AND);
// Let's build the SearchClassSpecification
SearchClassSpecification classSpec = new SearchClassSpecification();
classSpec.addSearchClass(Document.CLASS_NAME);
classSpec.addSearchClass(ContentObject.CLASS_NAME);
// Let's build the SearchSortSpecification
// Let' sort by context score. Note the use of contextClauseName
SearchSortSpecification sortSpec = new SearchSortSpecification();
sortSpec.add(Document.CLASS_NAME, ContextQualification.ORDER_PREFIX + "." + contextClauseName);
// Now that all 3 components are built, it is time to build
// AttributeSearchSpecification,nd attache the 3 components.
ContextSearchSpecification csp = new ContextSearchSpecification();
csp.setSearchClassSpecification(classSpec);
csp.setSearchQualification(sc);
csp.setSearchSortSpecification(sortSpec)
// Remember to set the context class name
csp.setContextClassname(ContentObject.CLASS_NAME);
// Now we are ready to construct the search object.
// You can even build a view at this point using ViewSpecification.
Search s = new Search(m_Session, csp);
// Open the search. This runs the query.
s.open();
// At this point you can do next() on the Search and get the SearchResultObject
// for each row in searcn result. After processing the results, remember to close
// the search.
// close
s.close();
- See Also:
- Serialized Form
Method Summary |
java.lang.String |
getContextClassname()
Returns the name of the class used for Text queries. |
void |
setContextClassname(java.lang.String cn)
Set the Class to be used for Text Queries. |
ContextSearchSpecification
public ContextSearchSpecification()
- Constructs a ContextSearchSpecification.
setContextClassname
public void setContextClassname(java.lang.String cn)
throws IfsException
- Set the Class to be used for Text Queries. The class should be a subClass
of ContentObject or ContentObject itself.
- Parameters:
cn
- Text Queries in ContextQualifications are applied on the content
of objects of this class.- Throws:
IfsException
- if the operation fails
getContextClassname
public java.lang.String getContextClassname()
throws IfsException
- Returns the name of the class used for Text queries.
- Returns:
- Context Search Class.
- Throws:
IfsException
- if the operation fails
(c) 2002 Copyright Oracle Corporation. All rights reserved.