Using Search Controls to Refine a Search

Search controls are specifications about how far and how long a search operation should look for a component or folder. The oracle.dss.bicontext.BISearchControls class embodies the search controls that you can set. The BISearchControls class allows you to specify the following controls:

Scoping options

The following constants specify how deeply in the namespace you want the search to take place. These constants are available in oracle.dss.bicontext.BISearchControls:

Example: Search results with different scoping levels set

The following folder structure shows a likely scenario in the BI Beans Catalog.


MyFolder   MySalesInfoFolder      MyGraphsFolder         MySalesBarGraph         MySalesPieGraph      MyCrosstabFolder         MySalesCrosstab   MyOperationsInfoFolder      MyOperationsCrosstab      MyOperationsBarGraph   MyTemplateGraph   MyTemplateBarGraph

You can specify attributes to refine the search for bar graphs. If you do an OBJECT_SCOPE search of MyFolder/MyTemplateGraph, and if MyTemplateGraph is a bar graph, then the search result enumeration will include:


MyFolder/MyTemplateGraph

If you do a ONELEVEL_SCOPE search for bar graphs from MyFolder, then the search result enumeration will include:


MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph

If you do a SUBTREE_SCOPE search for bar graphs from MyFolder, then the search result enumeration will include:


MyFolder/MySalesInfoFolder/MyGraphsFolder/MySalesBarGraph MyFolder/MyOperationsInfoFolder/MyOperationsBarGraph MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph

If you do a ONELEVEL_SCOPE_WITH_FOLDERS search for a bar graph from MyFolder, then the search result enumeration will contain search results for:


MyFolder MyFolder/MySalesInfoFolder MyFolder/MyOperationsInfoFolder MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph

If you do a SELECTIVE_ONELEVEL_SCOPE search for a bar graph from MyFolder, then the search result enumeration will contain search results for:


MyFolder MyFolder/MySalesInfoFolder MyFolder/MyOperationsInfoFolder MyFolder/MyTemplateGraph MyFolder/MyTemplateBarGraph

How to use search controls to refine a search operation

To use search controls to refine a search operation, you create a BISearchControls object. You call methods on the BISearchControls to set the controls as you want them. Then you pass the BISearchControls to a search method that takes a SearchControls as an argument.

Example: Searching for any folders that contain bar graphs

The following code searches for any folders that contain bar graphs, starting the search in a folder named MyFolder. This example uses SELECTIVE_ONELEVEL_SCOPE.


//pmRoot is the InitialPersistenceManager BasicAttributes _attrs = new BasicAttributes(); _attrs.put(PSRConstants.Attributes.OBJECT_TYPE, PSRConstants.GRAPH); _attrs.put(Graph.GRAPH_TYPE,   Graph.convertGraphTypeToString(Graph.BAR_VERT_CLUST)); BISearchControls _search = new BISearchControls(); _search.setSearchScope(BISearchControls.SELECTIVE_ONELEVEL_SCOPE); NamingEnumeration results = null; try{   results = pmRoot.search("", _attrs, _search); } catch(NamingException ne){   ne.printStackTrace(); }