This question periodically comes up in forum posts. The poster is usually looking to search
through ALL revisions of content.
Content Server doesn’t work that way. When using GET_SEARCH_RESULTS, only the
latest released content is searched and returned.
If the need is to only search metadata about an older item,
and not the full text of the content, a pretty nice workaround can be
used.
Content Server operates under the covers with some type of
SQL query, and a piece of logic called a “data source”. The concept can be leveraged for this
scenario by using an out of the box Content Server service called
“GET_DATARESULTSET”. http://docs.oracle.com/cd/E14571_01/doc.1111/e11011/c05_core002.htm#BABDCGHD.
A basic knowledge of the database
tables is necessary, and a working knowledge of the available data sources is
required.
The documentation describes the
service as below.
GET_DATARESULTSET
This service
executes a Select query against the database. The query is built from the
dataSource parameter. The service returns the following information:
- The resultset containing the results of the query.
- An indication if the results were truncated. If the dataSource was defined so it cannot exceed the maximum number of rows and if the query returns more than the maximum allowed, the copyAborted key is set to 1 (true). This indicates that the returned resultset only contains a subset of the query.
Any query
that tries to select against certain core Content Server tables have a security
clause applied. In particular, Documents, Revisions, and Users tables have
extra security clauses applied.
Location:
IdcHomeDir/resources/core/templates/std_services.htm
Additional
Required Service Parameters
- dataSource: A Select query with a potential WHERE clause and ORDER BY clause that is provided by the caller. The dataSource is a Content Server resource, defined in the DataSources table (see the resource.htm file for the standard list of dataSources.)
Optional Service Parameters
- whereClause: The WHERE clause to the Select query.
- orderClause: If set to true, orders the query by clause.
- resultName: specifies the name to use for the resultset of the query.
As a very
basic example, the following shows how to retrieve content that is NOT the
latest revision of a given content item from a URL (replace <the content
id> with a valid content id):
IdcService=GET_DATARESULTSET&dataSource=Documents&whereClause=dRevRank>0
and Revisions.dDocName='<the content
id>'&resultName=MyOldResults&IsSoap=1
Adding
“IsSoap” to the URL forces the return of the response in a SOAP format, because
the service does not have a template page associated with it. (Otherwise an error is thrown.) If you look in the result set “MyOldResults”,
the information about the old revisions is shown. It’s now a simple matter to construct a
GET_FILE service call to retrieve the old item.
RIDC
would look something like this:
binder.putLocal("IdcService","GET_DATARESULTSET");
binder.putLocal("dataSource","Documents");
binder.putLocal("whereClause","dRevRank>0
and Revisions.dDocName='<the content id>'");
binder.putLocal("resultName","MyOldResults");
ServiceResponse response =
client.sendRequest(userContext, binder);
The caveats
are:
- The number of results returned is limited to the system’s MaxResults setting.
- The results returned are restricted to the user’s security privilege. This is a GOOD caveat, as this isn’t a back door to retrieve content.