It's all about the answers!

Ask a question

ClearQuest OSLC 2.0 query pagination not working as expected

Aaron Lindsey (1111) | asked Sep 16 '15, 6:41 p.m.
I am running a query using the OSLC 2.0 REST API that returns ~6000 records. I am using rcm.startIndex and oslc.pageSize to get the records in pages of size 100. I would expect that page 1 would contain records 1-100, page 2 would contain records 101-200, etc. Instead, what is happening is that each page contains a seemingly random selection of 100 records out of the 6000. So instead of getting 6000 unique records, I end up with many duplicate records and some records are not returned.

The query looks like this:
GET in ["ABC", "123"] and cq:State!="Closed" and cq:Modified_Date>"2015-09-15T16:00:00Z"&oslc.prefix=cq=<>&
My algorithm works by increasing the startIndex by 100 until the total number of records are returned. I also tried using oslc.orderBy but I could not get that to work either.

Is this a limitation of the OSLC API? Or am I doing something wrong?

Aaron Lindsey commented Oct 21 '15, 4:29 p.m.

 Update: Even when I use the link in the oslc.nextPage attribute, I still see the same behavior. When I call the exact same URL more than once, I get a different set of results each time. It seems like no ordering is being enforced whatsoever.

2 answers

permanent link
Fernando Silva (8124) | answered Sep 17 '15, 12:30 a.m.
edited Sep 17 '15, 12:32 a.m.
 I think that you have to find the attribute rdf:resource at the tag oslc.nextPage  and use this url to retrieve the next page.

Aaron Lindsey commented Oct 20 '15, 4:47 p.m.

 Hi Fernando, unfortunately I tested it using the url in oslc.nextPage and got the same result.

permanent link
Donald Nong (14.5k414) | answered Sep 17 '15, 6:42 a.m.
I don't see this randomness in my own environment with a much smaller result set. Do you still see the randomness if you tighten up the search conditions? Also, how do you execute the query? Within some custom code or just a browser? I'm wondering whether the query is executed in a new user session every time you run it, or the result sets have not been cached.

As for oslc.orderBy, according to a very old post, the feature may not be implemented at all.

Aaron Lindsey commented Oct 21 '15, 4:33 p.m.

 Hi Donald, we tried to execute the query in a browser as well as using custom code and saw the same behavior for both. We noticed that if we remove cq:Product and cq:State filters from the oslc.where clause, the paging works as expected. It seems that we only see the randomness happening for certain oslc.where clauses.

Donald Nong commented Oct 21 '15, 9:20 p.m.

That's a bit strange. In this case, it's probably related to the way the SQL statement is constructed. If you can reproduce this issue on purpose, I would suggest you open a ticket with Support to confirm whether this is a defect.

Your answer

Register or to post your answer.