com.bea.content.expression
Class Search

java.lang.Object
  extended by com.bea.content.expression.Search
All Implemented Interfaces
Serializable, Cloneable

public class Search
extends Object
implements Cloneable, Serializable

This represents parameters for searching Nodes in the repository.

The search criteria are validated, but by default, will only print a WARNING to the WebLogic console if they are invalid. It is recommended that you enable full validation of the search critera, which will throw an Exception for invalid criteria; otherwise, the sort may fail to return valid or sorted results. To enable full validation, set this repository property in your content-config.xml: Run additional checks against search criteria searchValidation true

If not using full text search, the sort criteria are restricted to either system or explicit properties.

There are reserved system properties that may be part of a search. They are:

Explicit properties may be used as part of the sort criteria. They may be specified by the user, in addition to those that exist OOTB: "cm_nodeName", "cm_value","cm_lifeCycleStatus", "cm_isContent", "cm_isHierarchy", "cm_isHierarchy", "cm_objectClass", "cm_path", "cm_createdBy", "cm_createdDate", "cm_objectClassInstance", "cm_parent_uid", "cm_version", "cm_versionComment", "cm_checkedOut", "cm_assignedToUser", "cm_role", "cm_uid", "cm_modifiedBy", "cm_modifiedDate", "cm_contentType", "cm_binarySize", "cm_binaryName"

For more complex sort criteria, rather than SortCriteria, use the Search constructor that takes a sort string: public Search(String searchPath, int maxReturn, String sort, Expression expr) throws IllegalArgumentException where the 'sort' parameter may be something like:

Here is an example of how to build a search Expression:

    String expStr = "cm_objectClass = 'CATALOG_PRODUCT_ITEM' && keywords containsall ('camera')";
    Expression exp = ExpressionHelper.parse(expStr);
 

And here is an example of how that same search would be passed in as a String:

    String expStr = "cm_objectClass = 'CATALOG_PRODUCT_ITEM' && keywords containsall ('camera')";
 

Here is a full example of constructing and executing a search:

     IMetadataQuery mQuery = FullTextQueryFactory.getMetadataQuery();
     ITextQuery tQuery = FullTextQueryFactory.getTextQuery();
     String textString = "winter";
     ITextQueryParameter textCriteria = tQuery.buildEquals(textString);
     String metaDataString = "Nederland";
     IMetadataQueryParameter metadataCriteria = mQuery.buildContains("*", new String[]{metaDataString});
     IFullTextSearch expression = FullTextSearchFactory.buildFullTextSearch(metadataCriteria, textCriteria, true);
     String repositoryPath = "/MyRepository";
     Search search = new Search(repositoryPath, -1, null, expression, true);
     ISearchManager searchManager = ContentManagerFactory.getSearchManager();

     ContentContext cc = new ContentContext();
     cc.setParameter(ContentListKeys.BATCH_LOADING_SIZE_KEY, 100);
     ISortableFilterablePagedList results = searchManager.search(cc, search);

 

A note about search paths:

Note that Node link properties are not currently supported in a search expression.

See Also
Serialized Form

Field Summary
protected  Map contextParams
          The context params.
protected  Expression expression
          The search expression.
protected  IFullTextSearch fullText
          The full text search expression.
protected  int maxReturn
          The maximum number of objects to return.
protected  List searchPaths
          The paths under which to search.
protected  SortCriteria[] sortCriteria
          The sorting criteria
protected  boolean useCache
          indicates whether or not the search should use the cache or not
protected  boolean useFullTextSearch
          Whether a full text search is to be performed instead of a database search.
 
Constructor Summary
Search()
          Empty constructor.
Search(Expression expr)
          Constructor.
Search(int maxReturn, Expression expr)
          Constructor.
Search(int maxReturn, SortCriteria[] sortCriteria, Expression expr)
          Constructor.
Search(int maxReturn, SortCriteria[] sortCriteria, String expr)
          Constructor.
Search(int maxReturn, String expr)
          Constructor.
Search(int maxReturn, String sort, Expression expr)
          Constructor.
Search(int maxReturn, String sort, String expr)
          Constructor.
Search(String expr)
          Constructor.
Search(String searchPath, int maxReturn, SortCriteria[] sortCriteria, Expression expr)
          Constructor.
Search(String searchPath, int maxReturn, SortCriteria[] sortCriteria, IFullTextSearch expr, boolean performFullTextSearch)
          Constructor.
Search(String searchPath, int maxReturn, SortCriteria[] sortCriteria, String expr)
          Constructor.
Search(String searchPath, int maxReturn, String sort, Expression expr)
          Constructor.
Search(String searchPath, int maxReturn, String sort, String expr)
          Constructor.
 
Method Summary
 void addSearchPath(String path)
          Add a search path.
 void clearSearchPaths()
          Clear the search paths.
 Object clone()
          Make a deep copy of this object
 boolean equals(Object o)
          Determine if another object is equals to this.
 Object getContextParam(Object key)
          Get the value of a context param.
 Map getContextParams()
          Get an unmodifiable copy of the context params.
 Expression getExpression()
          Get the search expression.
 IFullTextSearch getFullTextExpression()
          Get the search expression corresponding to a full text search.
 int getMaxReturn()
          Get the maximum number of objects to return.
 int getNumSearchPaths()
          Get the number of search paths set directly on the Search object.
 String[] getSearchPaths()
          Get the search paths.
 Iterator getSearchPathsIterator()
          Get an iterator over the search paths.
 SortCriteria[] getSortCriteria()
          Get the sort criteria.
 int hashCode()
          Override hashcode to use our parts.
 boolean isFullTextSearch()
          Check if this is a Full Text Search instead of the Database Search.
 boolean isUseCache()
          Indicates whether or not the search, when executed will try to use the global search cache or not.
 void removeSearchPath(String path)
          Remove a search path.
 Object setContextParam(Object key, Object value)
          Set the value of a context param.
 void setContextParams(Map input)
          Set the context params based upon the objects in the input map.
 void setExpression(Expression expression)
          Set the search expression.
 void setFullTextExpression(IFullTextSearch expression)
          Set the search expression corresponding to a full text search.
 void setFullTextSearch(boolean fullTextSearch)
          Enable/Disable Full Text Search
 void setMaxReturn(int maxReturn)
          Set the maximum number of objects to return.
 void setSearchPath(String searchPath)
          Set the search path to contain just this one.
 void setSearchPaths(String[] paths)
          Set the search paths.
 void setSortCriteria(SortCriteria[] sortCriteria)
          Set the sort criteria.
 void setSortCriteria(String sort)
          Set the sort criteria.
 void setUseCache(boolean useCache)
          Indicates to the search API whether or not to use the search cache when executing the search expression.
 String toString()
          Get a String representation of this.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

searchPaths

protected List searchPaths
The paths under which to search.

This should be empty to search under all paths (repositories in a federeated search.) This is an OR'ed list.

In a federated search, this can begin with "/*" (e.g."/*/some/path") to denote a search path under each repository. In non-federated search, this should not be construed to contain any special characters.


maxReturn

protected int maxReturn
The maximum number of objects to return.

Less than 0 signifies returning all matches.


sortCriteria

protected SortCriteria[] sortCriteria
The sorting criteria


expression

protected Expression expression
The search expression.


fullText

protected IFullTextSearch fullText
The full text search expression.


contextParams

protected Map contextParams
The context params.

Note from com.bea.p13n.content.expression.Search: Attribute: contextParams

  • Containment: By Value
  • Multiplicity: 1:1
  • This can other arbitrary parameters to pass through to the document manager. Only Serializable objects should go into this. These are not used to determine equality.


useCache

protected boolean useCache
indicates whether or not the search should use the cache or not


useFullTextSearch

protected boolean useFullTextSearch
Whether a full text search is to be performed instead of a database search.

Constructor Detail

Search

public Search(String searchPath,
              int maxReturn,
              SortCriteria[] sortCriteria,
              IFullTextSearch expr,
              boolean performFullTextSearch)
Constructor.

Parameters
searchPath - The path to search within, thus limiting the scope of the search. If this is null, then all content in all repositories will be searched. If you wish to search only one repository, the path will be something like "/MyRepository". If you wish to further scope that search in that repository beneath a folder called "Accounts", the search path will be "/MyRepository/Accounts". Multiple search paths can be added by calling 'addSearchPath()" once the Search object has been created. Search paths set directly on the Search object imply recursive search beneath that folder, if the underlying repository supports it.
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sortCriteria - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.
performFullTextSearch - Setting this to true will search binary data (eg, file content). Setting it to false will search only metadata.

Search

public Search(String searchPath,
              int maxReturn,
              SortCriteria[] sortCriteria,
              Expression expr)
Constructor.

Parameters
searchPath - The path to search within, thus limiting the scope of the search. If this is null, then all content in all repositories will be searched. If you wish to search only one repository, the path will be something like "/MyRepository". If you wish to further scope that search in that repository beneath a folder called "Accounts", the search path will be "/MyRepository/Accounts". Multiple search paths can be added by calling 'addSearchPath()" once the Search object has been created. Search paths set directly on the Search object imply recursive search beneath that folder, if the underlying repository supports it.
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sortCriteria - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.

Search

public Search(String searchPath,
              int maxReturn,
              SortCriteria[] sortCriteria,
              String expr)
       throws IllegalArgumentException
Constructor.

Parameters
searchPath - The path to search within, thus limiting the scope of the search. If this is null, then all content in all repositories will be searched. If you wish to search only one repository, the path will be something like "/MyRepository". If you wish to further scope that search in that repository beneath a folder called "Accounts", the search path will be "/MyRepository/Accounts". Multiple search paths can be added by calling 'addSearchPath()" once the Search object has been created. Search paths set directly on the Search object imply recursive search beneath that folder, if the underlying repository supports it.
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sortCriteria - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(String searchPath,
              int maxReturn,
              String sort,
              Expression expr)
       throws IllegalArgumentException
Constructor.

Parameters
searchPath - The path to search within, thus limiting the scope of the search. If this is null, then all content in all repositories will be searched. If you wish to search only one repository, the path will be something like "/MyRepository". If you wish to further scope that search in that repository beneath a folder called "Accounts", the search path will be "/MyRepository/Accounts". Multiple search paths can be added by calling 'addSearchPath()" once the Search object has been created. Search paths set directly on the Search object imply recursive search beneath that folder, if the underlying repository supports it.
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sort - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(String searchPath,
              int maxReturn,
              String sort,
              String expr)
       throws IllegalArgumentException
Constructor.

Parameters
searchPath - The path to search within, thus limiting the scope of the search. If this is null, then all content in all repositories will be searched. If you wish to search only one repository, the path will be something like "/MyRepository". If you wish to further scope that search in that repository beneath a folder called "Accounts", the search path will be "/MyRepository/Accounts". Multiple search paths can be added by calling 'addSearchPath()" once the Search object has been created. Search paths set directly on the Search object imply recursive search beneath that folder, if the underlying repository supports it.
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sort - The sort criteria. Can be null. An example would be: "cm_nodeName", which would sort results by node name.
expr - The search expression.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(int maxReturn,
              SortCriteria[] sortCriteria,
              Expression expr)
Constructor. Since the search path is not specified, all content of all repositories will be searched.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sortCriteria - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(int maxReturn,
              SortCriteria[] sortCriteria,
              String expr)
       throws IllegalArgumentException
Constructor. Since the search path is not specified, all content of all repositories will be searched.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sortCriteria - The sort criteria. This can be null, and if so, results are returned unsorted. If multiple sortCriteria are specified in the array, the first specified will be the primary, and the next the secondary, etc.
expr - The search expression.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(int maxReturn,
              String sort,
              Expression expr)
       throws IllegalArgumentException
Constructor. Since the search path is not specified, all content of all repositories will be searched.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sort - The sort criteria. Can be null. An example would be: "cm_nodeName", which would sort results by node name.
expr - The search expression. See javadocs at the top of this class for an example.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(int maxReturn,
              String sort,
              String expr)
       throws IllegalArgumentException
Constructor. Since the search path is not specified, all content of all repositories will be searched.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
sort - The sort criteria. Can be null. An example would be: "cm_nodeName", which would sort results by node name.
expr - The search expression. See javadocs at the top of this class for an example.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(int maxReturn,
              Expression expr)
Constructor. If the search path is not specified in the Expression, all content of all repositories will be searched. Search results are returned unsorted.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
expr - The search expression. See javadocs at the top of this class for an example.

Search

public Search(int maxReturn,
              String expr)
       throws IllegalArgumentException
Constructor. If the search path is not specified in the expression, all content of all repositories will be searched. Search results are returned unsorted.

Parameters
maxReturn - The maximum number of results to return. Less than 0 signifies returning all matches.
expr - The search expression. See javadocs at the top of this class for an example.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search(Expression expr)
Constructor. If the search path is not specified in the Expression, all content of all repositories will be searched. All matches will be returned, unsorted.

Parameters
expr - The search expression. See javadocs at the top of this class for an example.

Search

public Search(String expr)
       throws IllegalArgumentException
Constructor. If the search path is not specified in the Expression, all content of all repositories will be searched. All matches will be returned, unsorted.

Parameters
expr - The search expression. See javadocs at the top of this class for an example.
Throws
IllegalArgumentException - If the construction failed.

Search

public Search()
Empty constructor. All content in all repositories will be searched and all results will be returned unsorted.

Method Detail

isFullTextSearch

public boolean isFullTextSearch()
Check if this is a Full Text Search instead of the Database Search. A full text search implies the use of a full text search engine that indexes both binary (e.g., document content) and metadata (e.g., document properties). Otherwise, a 'Database' search implies searching only metadata in the CM content repository backing store.

Returns
true - to indicate that full text search is being used.

setFullTextSearch

public void setFullTextSearch(boolean fullTextSearch)
Enable/Disable Full Text Search

Parameters
fullTextSearch - Setting this to true will search binary data (e.g., file content) and metadata. Setting it to false will search only metadata in the CM repository backing store.

getSearchPaths

public String[] getSearchPaths()
Get the search paths. These are the paths set directly on the Search object, not those contained in the Expression or FullTextSearch objects. Search paths imply recursive search beneath that folder, if the underlying repository supports it.

See searchPaths for details about what this can be.

Returns
An array of search paths.

getSearchPathsIterator

public Iterator getSearchPathsIterator()
Get an iterator over the search paths. These are the paths set directly on the Search object, not those contained in the Expression or FullTextSearch objects.

See searchPaths for details about what this can be.

Returns
An Iterator of search paths.

getNumSearchPaths

public int getNumSearchPaths()
Get the number of search paths set directly on the Search object.

Returns
The number of search paths.

setSearchPath

public void setSearchPath(String searchPath)
Set the search path to contain just this one. Search paths imply recursive search beneath that folder, if the underlying repository supports it.

See searchPaths for details about what this can be.

Parameters
searchPath - The search path.

setSearchPaths

public void setSearchPaths(String[] paths)
Set the search paths. Search paths imply recursive search beneath that folder, if the underlying repository supports it. Note that some repositories may only support a single search path.

Parameters
paths - The search paths.

addSearchPath

public void addSearchPath(String path)
Add a search path. Search paths imply recursive search beneath that folder, if the underlying repository supports it. Note that some repositories may only support a single search path.

See searchPaths for details about what this can be.

Parameters
path - The search path to add.

removeSearchPath

public void removeSearchPath(String path)
Remove a search path.

Parameters
path - The path to remove.

clearSearchPaths

public void clearSearchPaths()
Clear the search paths.


getMaxReturn

public int getMaxReturn()
Get the maximum number of objects to return.

Use less than 0 to signify returning all matches.

Returns
The maximum number of items to return.

setMaxReturn

public void setMaxReturn(int maxReturn)
Set the maximum number of objects to return.

Use less than 0 to signify returning all matches.

Parameters
maxReturn - The maximum number of items to return.

getSortCriteria

public SortCriteria[] getSortCriteria()
Get the sort criteria.

Returns
The sort criteria.

setSortCriteria

public void setSortCriteria(SortCriteria[] sortCriteria)
Set the sort criteria.

Parameters
sortCriteria - The sort criteria.

setSortCriteria

public void setSortCriteria(String sort)
                     throws IllegalArgumentException
Set the sort criteria.

Parameters
sort - The sort criteria.
Throws
IllegalArgumentException - if the str string isn't valid occurred to SortCriteria.getSortCriteria(java.lang.String).

getExpression

public Expression getExpression()
Get the search expression.

Returns
The search expression.

getFullTextExpression

public IFullTextSearch getFullTextExpression()
Get the search expression corresponding to a full text search.

Returns
The full text search expression.

setFullTextExpression

public void setFullTextExpression(IFullTextSearch expression)
Set the search expression corresponding to a full text search.

Parameters
expression - The full text search expression.

setExpression

public void setExpression(Expression expression)
Set the search expression.

Parameters
expression - The search expression.

getContextParams

public Map getContextParams()
Get an unmodifiable copy of the context params.

Returns
The context parameters.

setContextParams

public void setContextParams(Map input)
Set the context params based upon the objects in the input map.

Parameters
input - The context parameters.

getContextParam

public Object getContextParam(Object key)
Get the value of a context param.

Returns
key The context parameter key.

setContextParam

public Object setContextParam(Object key,
                              Object value)
Set the value of a context param.

The key and value must be Serializable.

Parameters
key - the context param key.
value - the context param value.
Returns
the old context param value or null if none.

clone

public Object clone()
Make a deep copy of this object

Overrides:
clone in class Object

hashCode

public int hashCode()
Override hashcode to use our parts.

Overrides:
hashCode in class Object

isUseCache

public boolean isUseCache()
Indicates whether or not the search, when executed will try to use the global search cache or not. The default value is true, so every search will try to find data in the search cache first.

Returns
true if the search will use the global search cache

setUseCache

public void setUseCache(boolean useCache)
Indicates to the search API whether or not to use the search cache when executing the search expression. The default value is true, so every search will try to find data in the search cache first. If set to false the search cache will be ignored when querying.

Parameters
useCache - variable indicating whether or not to use the search cache.

equals

public boolean equals(Object o)
Determine if another object is equals to this.

Overrides:
equals in class Object

toString

public String toString()
Get a String representation of this.

Overrides:
toString in class Object


Copyright © 2011, Oracle. All rights reserved.