Uploaded image for project: 'Alfresco One Platform'
  1. Alfresco One Platform
  2. ACE-5827

'totalItems' is lost when adding a sort field to a search query (V1 API)

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Critical
    • Resolution: Not a bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
    • Environment:
      Alfresco 5.2.3 / SOLR4 and Search Services 1.1.0.2
    • Bug Priority:
      Category 2

      Description

      Description
      When adding a sort field to a search query using the V1 API, the returned 'totalItems' field is lost.

      Steps to reproduce
      Using the Search V1 API (api-explorer), run a query with the following queryBody:

      {
         "query": {
             "language": "afts",
             "userQuery": null,
             "query": "TYPE:'cm:folder'"
         },
         "paging": {
             "maxItems": 10,
             "skipCount": 0
         },
         "include": ["properties", "aspectNames"],
         "fields": null,
         "sort": [
              {
             "type": "FIELD",
             "field": "TYPE",
             "ascending": "false"
         }],
         "templates": null,
         "defaults": null,
         "filterQueries": null,
         "facetQueries": null,
         "facetFields": null,
         "spellcheck": null,
         "scope": null,
         "limits": null,
         "highlight": null,
         "pivots": null
      }
      • the responseBody will contain ({totalItems}}:
        {
          "list": {
            "pagination": {
              "count": 10,
              "hasMoreItems": true,
              "totalItems": 105,
              "skipCount": 0,
              "maxItems": 10
            },
        	....

      Now run the same query but with a sort field included, such as cm:created, i.e.

      {
         "query": {
             "language": "afts",
             "userQuery": null,
             "query": "TYPE:'cm:folder'"
         },
         "paging": {
             "maxItems": 10,
             "skipCount": 0
         },
         "include": ["properties", "aspectNames"],
         "fields": null,
         "sort": [
              {
             "type": "FIELD",
             "field": "cm:created",
             "ascending": "false"
         }],
         "templates": null,
         "defaults": null,
         "filterQueries": null,
         "facetQueries": null,
         "facetFields": null,
         "spellcheck": null,
         "scope": null,
         "limits": null,
         "highlight": null,
         "pivots": null
      }
      • totalItems is now missing from the response:
      {
        "list": {
          "pagination": {
            "count": 10,
            "hasMoreItems": true,
            "skipCount": 0,
            "maxItems": 10
          },
      	....

      Workarounds
      1. As per this community post, add additional criteria to the search such as AND -TYPE:'dummyType', i.e.

      {
         "query": {
             "language": "afts",
             "userQuery": null,
             "query": "TYPE:'cm:folder' AND -TYPE:'dummyType'"
         },
         ....

      2. Switch off TMDQ for AFTS queries (set to 'never use database').

      Environment
      Alfresco 5.2.3 tested against both SOLR4 and Search Services 1.1.0.2

        Attachments

          Structure

            Activity

              People

              • Assignee:
                closedissues Closed Issues
                Reporter:
                astrachan Alex Strachan
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Structure Helper Panel