-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 8.10, 9.3-SNAPSHOT
-
Fix Version/s: 9.10
-
Component/s: Core, Query & PageProvider
-
Epic Link:
-
Sprint:nxcore 9.3.10, nxcore 9.10.1
-
Story Points:3
When executing a query like
SELECT dc:subjects/* FROM File WHERE ecm:name = 'doc1'
returns a total size of 1 even if result set is empty.
Easy reproduction use case
- create a Collection
- send a GET request on the Rest API
http://localhost:5000/nuxeo/api/v1/search/pp/ordered_content_collection/execute?offset=0&pageSize=40&queryParams={collectionUuid}
- observe the response
{"entity-type":"documents","isPaginable":true,"resultsCount":1,"pageSize":43,"maxPageSize":1000,"resultsCountLimit":43,"currentPageSize":0,"currentPageIndex":0,"currentPageOffset":0,"numberOfPages":1,"isPreviousPageAvailable":false,"isNextPageAvailable":false,"isLastPageAvailable":false,"isSortable":true,"hasError":false,"errorMessage":null,"totalSize":1,"pageIndex":0,"pageCount":1,"entries":[]}
saying "resultsCount":1 but with empty entries.
Reason
Probably caused by the LEFT JOIN between subject id and hierarchy id in the tranlasted query:
SELECT DC_SUBJECTS.ITEM FROM HIERARCHY LEFT JOIN DC_SUBJECTS ON HIERARCHY.ID = DC_SUBJECTS.ID LEFT JOIN DUBLINCORE ON HIERARCHY.ID = DUBLINCORE.ID WHERE HIERARCHY.PRIMARYTYPE IN (?, ?) AND HIERARCHY.NAME = ? ORDER BY DUBLINCORE.TITLE, HIERARCHY.ID, DC_SUBJECTS.POS
Unit test
@Test public void testQueryIdListNotFromUuidTotalSize() throws Exception { // We need at least such a doc which will make the left join return a null DocumentModel doc1 = new DocumentModelImpl("/", "doc1", "File"); doc1 = session.createDocument(doc1); doc1 = session.saveDocument(doc1); session.save(); DocumentModelList dml; String query = "SELECT dc:subjects/* FROM File WHERE ecm:name = 'doc1'"; dml = session.query(query, null, 10, 0, true); assertEquals(0, dml.totalSize()); }
- is duplicated by
-
NXP-23641 Page provider resultsCount not correctly computed on mongodb
- Resolved