IBM Enterprise Records, Version 5.1.2    

Executing an ad hoc search to return paged results

To perform an ad hoc search and return paged results, use the RMPagedSearch interface. Instantiate an RMPagedSearch object by calling the RMObjectStore.getRMPagedSearch() method.

After obtaining an RMPagedSearch object, first call the singleObjectTypeExecute method to perform a search. Then use nextPage/nextPageXML or previousPage/previousPageXML to return paged results.
  • singleObjectTypeExecute

The following table provides a description of these parameters.

Parameter Description
asSearchSQLstmt Contains a valid SQL statement string that defines the criteria for searching metadata in a FPOS. If only content is to be searched, this parameter contains properties, such as ID and aggregation, that identify the objects to be searched. It must contain the ClassDescription property in the SELECT list. For example, SELECT d.DocumentTitle, d.ClassDescription, d.Creator FROM Document d WHERE d.[DocumentTitle] LIKE '%abc%'.

The SELECT statement for this parameter needs to be the same as in the asNonPropSQLstmt parameter.

asNonPropSQLstmt This is only needed when the asOperator parameter is OR. It contains a valid SQL statement string containing non-property related conditions like specifying the file plan or class. For example, SELECT d.DocumentTitle, d.ClassDescription, d.Creator FROM Document d WHERE (d.This insubfolder '/Records Management/File Plan').

If the asOperator parameter is "AND", set this value as null.

asContentSearchWhereClause Contains a string that defines the WHERE clause for a content-based search in the Record Object Store (ROS). For example, contains(content, '(testCBR)')

For a metadata search, this parameter needs to be null.

asOperator Contains a string specifying either the moOR_OPERATOR or moAND_OPERATOR operator to indicate the merge option for the metadata or content search on the FPOS and the content search on the ROS.

This parameter cannot be null if the asContentSearchWhereClause is provided.

aiObjectType An int value identifying the type of object to be searched. The object type must be either BaseObject.TYPE_DOCUMENT or BaseObject.TYPE_FOLDER
pageSize A positive int value specifying the size of the returned pages.
filterByParent
A boolean value specifying if the query contains the "filter by parent" clause and should only be used in the asSearchSQLstmt parameter. True indicates the query contains the "filter by parent" clause. False indicates that there is no "filter by parent" clause in the query. For example, the filterByParent parameter should be set to false if the following values are passed for the asSearchSQLstmt parameter:

SELECT d.Id, d.ClassDescription FROM ([RecordFolder] f inner join ReferentialContainmentRelationship r on f.This=r.Tail) inner Join [RecordInfo] d on d.This=r.Head WHERE ((d.[isDeleted] = false) and ((f.[IsHiddenContainer] = false) and (f.[RecordFolderName] LIKE '%test%'))) and (d.[VersionStatus] = 1) and d.[isDeleted] = false

To return and navigate through the paged results, you can use the following methods:
  • nextPage: This method moves the iterator to the first page of the results on the first call and to the next page in the set on subsequent calls. nextPage returns an array of objects on that page, but returns null if the current iterator is at the last page. The objects are of the type found in com.filenet.api.collection.RepositoryRowSet.
  • nextPageXML: This method functions the same as the nextPage method except that the results are returned in a P8 object set XML format.
  • previousPage: This method moves the iterator to the previous page and returns an array of objects in the page. The objects are of the type found in com.filenet.api.collection.RepositoryRowSet. If the current iterator is at the first page, previousPage returns null.
  • previousPageXML: This method functions the same as the previousPage method except that the results are returned in a P8 object set XML format.
You can also use the following methods to check the existence of the previous or next page:
  • hasNextPage
  • hasPreviousPage

RM paged search is implemented based on P8 Content Platform Engine Java API.

Sample 1
This example demonstrates how to instantiate an RMPagedSearch object and to execute a search to return each page of results in a P8 objectset XML format.
    ObjectStore loStore = ObjectFactory.getObjectStore (asObjectStoreName, aoSession);


    // creates an object of RMObjectStore and instantiate RMPagedSearch.
   RMObjectStore loRMStore = new RMUtil().getRMObjectStore(loStore);
  RMPagedSearch pagedSearch = loRMStore.getRMPagedSearch();
  
  String stmt = "Select d.DocumentTitle, d.Creator, d.DateCreated, d.ClassDescription from Document d Where d.Creator='jdoe'";
  String asContentSearchWhereClause = "(contains(content, '(testCBR)'))";
  String asOperator = "AND";
  int pageSize = 50; // set to return 50 documents each page call.
  
  pagedSearch.singleObjectTypeExecute(asSearchSQLstmt, null, asContentSearchWhereClause, asOperator, 
BaseObject.DOCUMENT_TYPE, pageSize, false);
  while (pagedSearch.hasNextPage())
  {
        String objectsetXML = pagedSearch.nextPageXML();
        system.out.println(objectsetXML);
  }
Sample 2
This example demonstrates how to navigate through each page and how to use P8 Content Engine Java API to retrieve values from a returned rowset.
    ObjectStore loStore = ObjectFactory.getObjectStore (asObjectStoreName, aoSession);


    // creates an object of RMObjectStore and instantiate RMPagedSearch.
   RMObjectStore loRMStore = new RMUtil().getRMObjectStore(loStore);
  RMPagedSearch pagedSearch = loRMStore.getRMPagedSearch();
  
  String stmt = "Select d.DocumentTitle, d.Creator, d.DateCreated, d.ClassDescription from Document d Where d.[DocumentTitle] LIKE '%doc%'";
  String asContentSearchWhereClause = "(contains(content, '(testCBR)'))";
  String asOperator = "AND";
  int pageSize = 50; // set to return 50 documents each page call.
  
  pagedSearch.singleObjectTypeExecute(asSearchSQLstmt, null, asContentSearchWhereClause, asOperator, 
BaseObject.DOCUMENT_TYPE, pageSize, false);
  while (pagedSearch.hasNextPage())
  {
      Object[] rowset = pagedSearch.nextPage();

      int size= (rowset!= null) ? rowset.length : 0;
      for (int i = 0; i < size; i++)
      {
             RepositoryRow row = (RepositoryRow)rowset[i];
             String docTitle = row.getProperties().getStringValue("DocumentTitle");
             system.out.println(docTitle);
      }
  }
Sample 3
For a query that combines a property and content search with the AND operator and sorts by a property, a subsequent call of nextPage() or nextPageXML() sometimes returns empty results, even though hasNextPage() returns a true value. If this happens, it is an indication that the search has reached the end of the result set. The following code sample illustrates this behavior:
  RMPagedSearch pagedSearch = objStore.getRMPagedSearch();
  String stmt = "Select d.DocumentTitle, d.ClassDescription from Document d Where d.Creator='jdoe' order by 
         d.DocumentTitle";
  String asNonPropSQLstmt = null;
  String asContentSearchWhereClause = "(contains(content, '(testCBR)'))";
  String asOperator = "AND";
  int pageSize = 50; // set to return 50 documents each page call.
  boolean filterByParent=false;
  pagedSearch.singleObjectTypeExecute(stmt,asNonPropSQLstmt, asContentSearchWhereClause, asOperator, BaseObject.TYPE_DOCUMENT,
         pageSize, filterByParent)

  while (pagedSearch.hasNextPage())
        {
                        Object[] rowset = pagedSearch.nextPage();
                        if (rowset == null || rowset.size() == 0)
                        {
                                // The end of paging. No more search results.
                                break;
                        }
                        else
                        {
                                //Process rowset ...
                                ...
                        }
                }


Feedback

Last updated: November 2013
ierdg041.htm

© Copyright IBM Corporation 2013