You can build queries that perform three main types of searches: parametric, text, and combined parametric and text. To run a query, you can use one of the following methods: evaluate, execute, or executeWithCallback.
A parametric query uses conditions such as equality and comparison. A text query uses text search functions, which make the search more thorough. A combined query is composed of both text and parametric conditions.
When you query the IBM® Content Manager library server, you complete the following main steps:
The evaluate method returns all results as a collection of DDOs. The default options work well for result sets that are relatively small, 200 items or less. When working with larger results sets, specify the IDONLY retrieve option to prevent attribute data from being stored in the DDOs that are returned. In this case, you must explicitly retrieve the attribute data for the DDOs because the data is needed by the application. You can limit the result set size by using the max results option.
The executeWithCallback method executes a query in an asynchronous manner and sends the results to the specified callback object in blocks. As such, the executeWithCallback method frees up the main thread of execution from the task of retrieving query results. See the Application Programming Reference for a description of the query options of the execute method.
Starting with IBM Content Manager Version 8 Release 3, there are two ways you can get the count of query results without retrieving the results themselves. One way is through the executeCount method in DKDatastoreICM, and the other way is through the cardinality method in dkResultSetCursor. The executeCount method in DKDatastoreICM takes in a query string and options and returns the estimated count of the results of the query. The cardinality method in dkResultSetCursor, implemented in the IBM Content Manager Version 8 connector, allows you to obtain the count when you already have a dkResultSetCursor. This call requires a separate trip to the server to evaluate the count.
The count of query results can be different from the number of results that you would get when running the query and getting the results. This result occurs because the count is accurate only at an instant in time. Items might be added or deleted between the time the count is retrieved and when the results are retrieved. There are also a few cases in which query might return the ID of an item, but the retrieve API cannot access that item. In these cases, the count is also inaccurate. To get an accurate count, a server call must be made to evaluate the query, which means that if you want the count and then the results, you must make two trips to the server.
For more information about query methods, see the SSearchICM sample. See the Application Programming Reference for the evaluate, execute, or executeWithCallback methods in DKDatastoreICM class.
