4

Are there any methods to page queries in FileNet? I have a grid control with paging so i need to get count of elements total in query and possibility to get in example page 3 of results(with any page size). I found only TOP operator, but are there any SKIP or COUNT?

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
Horosho
  • 647
  • 1
  • 8
  • 22

2 Answers2

3

There is no way to accomplish exactly what you want. The main reason for this is that it is very expensive for Content Engine to count all rows returned by a query (assuming there are thousands of them). There can be quite involved security restrictions that potentially have to be applied to each returned object. This will effectively exclude some objects from query results, affecting the result count. Evaluating effective security permissions on multiple objects would kill the performance, thus avoided. That is why you don't have COUNT or other aggregate functions in the query language.

If you can restrict the amount of records displayed in the grid to a reasonable number, then COUNT_LIMIT might work for you — see Query Options and getTotalCount(). However, this will require looping through to the required page with its inherent performance drawback.

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
  • @Horosho This might lead you to the idea to rethink the UI. This is not database after all. – ᄂ ᄀ Apr 08 '15 at 18:08
  • 1
    may be, but paging and random page access in grids is standard feature, so it is really big limitation for UI, especially for WebUI – Horosho Apr 09 '15 at 06:47
  • @Horosho The key is to question why anyone needs random page access. It can easily turn out there is no practical value in this. UI should be driven by the real needs of its users, not perceived "standardness". – ᄂ ᄀ Apr 09 '15 at 08:04
0

Here is a good link with a backend example on how the paging works:

Paging example

as for the totals count, this should be in the pageiterator object: pageIterator api page

In this case you'd need to manually keep track of the paging in the UI

or as an alternative, install, configure and implement CMIS to perform the operations, that has page skipping as default functionalty

CMIS infocenter

Robert vd S
  • 342
  • 1
  • 6
  • I've seen this chapter, but i still don't understand, how can i get needed page by number? I should loop pages till i get it? How can i get total count? – Horosho Mar 04 '15 at 08:19
  • At a project where I worked they did exactly that, set the page size accordingly and page through it. That solution redid the entire query, but if you can keep it statefull you should be able to skip the redo of the query. This was actually done with cmis. Perhaps this is a good solution as it is an ecm wide standard in accessing document management systems. http://www-01.ibm.com/support/knowledgecenter/SSNW2F_5.2.0/com.ibm.installingp8cmis.doc/cmidv000.htm?cp=SSNW2F_5.2.0%2F4-12-5 If not you'll have to do the skip count manually keep track of what page you are – Robert vd S Mar 04 '15 at 10:47
  • I think this looks a bit "untidy code", and i still can't get total with it. Now i get all data and page it on client - this is not good idea too =( – Horosho Mar 04 '15 at 12:56
  • the page iterator should have a total count function according to the documentation: http://www-01.ibm.com/support/knowledgecenter/SSNW2F_5.2.0/com.ibm.p8.ce.dev.java.doc/com/filenet/api/collection/PageIterator.html%23getTotalCount%28%29 this could aide in the totals count – Robert vd S Mar 05 '15 at 09:44
  • I tried to use page skipping, but results for pages after 10-15 are to slow. FileNet API performs 10-15 queries. I'm in search for "best practice". – Horosho Mar 05 '15 at 10:23
  • If it is very slow, perhaps you need to place some indexes on the datamodel. You can do that from the fem itself. A few well placed indexes can make all the diference: http://www-01.ibm.com/support/knowledgecenter/SSNW2F_5.2.0/com.ibm.p8.ce.admin.tasks.doc/pr_create_db_column_indexes002_copyto_all.htm – Robert vd S Mar 05 '15 at 10:56
  • I'm not sure it helps, i'm iterating all class items without any condition – Horosho Mar 05 '15 at 11:01
  • @RobertvdS This is not related to indexes in any way. The reason page iterator slows down when you go deeper is by design - it needs to go through previous pages. Please stop your ill-informed "consulting" regarding FileNet here on SO. – ᄂ ᄀ Apr 04 '15 at 13:06
  • @fnt Ahh, and another big thanks for trying to help people. I know this is difficult and I wasn't talking about database indexes. On a project I have a simular solution to what Horosho was referring. So with that I mind I gave him advice on solutions on how he can solve this. So please keep your sour opinions to yourself! – Robert vd S Apr 07 '15 at 06:05
  • My opinions are strictly about the proposed "solutions". Why should I keep them to myself if advice is unprofessional? – ᄂ ᄀ Apr 07 '15 at 09:10