You are here

facetFields

The facetFields element specifies the simple facet fields to include in a query. These facets are generated by counting field values for all results that match the query. This is the default behaviour of all the filter queries applied.

Parameters

The parameter for the facetFields element is:
Parameter Type Description
facets String A simple facet field that defines specific fields on which to facet.
The filters used with the facets parameter are:
Filters Type Description
field String This specifies the facet field.
label String This specifies the label to include in place of the facet field. To use a label containing spaces the string must be surrounded by double quotes.
prefix String This restricts the possible constraints to only indexed values with a specified prefix.
sort String The available values are COUNT and INDEX.
method String The available values are ENUM and FC.
missing boolean When true, it counts the results that match the query but which have no facet value for the field (in addition to the term-based constraints). The default value is false.
limit Integer  
offset Integer  
mincount Integer This specifies the minimum count required for a facet field to be included in the response. The default value is 1.
facetEnumCacheMinDf Integer  
excludeFilters String This specifies that the filter queries with tags listed here will not be included in facet counts. This is used for multi-select faceting.
Note: Only facetFields support exclude for multi-select facets. Range, pivot, or intervals do no support exclude.

Examples

Example 1: You can specify several facet fields using the facetFields JSON body parameter, for example:

"facetFields": {"facets": [{"field": "creator", "mincount": 1}, {"field": "modifier", "mincount": 1}]}

Response: The result contains a matching context section and the label will match the facet field.

"context": {
   "facetsFields": [
     {  "label": "creator",
        "buckets": [
          { "label": "System", "count": 75 },
          { "label": "mjackson", "count": 5 }
        ]},
     {  "label": "modifier",
        "buckets": [
          { "label": "System", "count": 72 },
          { "label": "mjackson", "count": 5 },
          { "label": "admin", "count": 3 }
        ]}
   ]
},
Example 2: Instead of nesting facet fields in a pivot, you can also use flat facet, as shown below:
{
   "query": {
      "query": "name:*" 
   },
   "facetFields": {
      "facets": [
         {"field": "content.mimetype", "label": "mimetype"},
         {"field": "SITE", "label": "site"},
         {"field": "TYPE", "label": "type"}
      ]
    }
}
Response:
"facetsFields": [
                {
                    "label": "type",
                    "buckets": [
                        {
                            "label": "{http://www.alfresco.org/model/content/1.0}category",
                            "filterQuery": "TYPE:\"{http://www.alfresco.org/model/content/1.0}category\"",
                            "count": 335
                        },
                      ...
                        {
                            "label": "{http://www.alfresco.org/model/system/1.0}store_root",
                            "filterQuery": "TYPE:\"{http://www.alfresco.org/model/system/1.0}store_root\"",
                            "count": 1
                        },
                        {
                            "label": "{http://www.alfresco.org/model/transfer/1.0}transferGroup",
                            "filterQuery": "TYPE:\"{http://www.alfresco.org/model/transfer/1.0}transferGroup\"",
                            "count": 1
                        }
                    ]
                },
                {
                    "label": "site",
                    "buckets": [
                        {
                            "label": "_REPOSITORY_",
                            "filterQuery": "SITE:\"_REPOSITORY_\"",
                            "count": 711
                        },
                        {
                            "label": "swsdp",
                            "filterQuery": "SITE:\"swsdp\"",
                            "count": 103
                        },
                        {
                            "label": "surf-config",
                            "filterQuery": "SITE:\"surf-config\"",
                            "count": 2
                        }
                    ]
                },
                {
                    "label": "mimetype",
                    "buckets": [
                        {
                            "label": "text/plain",
                            "filterQuery": "content.mimetype:\"text/plain\"",
                            "count": 120,
                            "display": "Plain Text"
                        },
                        {
                            "label": "image/png",
                            "filterQuery": "content.mimetype:\"image/png\"",
                            "count": 38,
                            "display": "PNG Image"
                        },
                        ...
                        {
                            "label": "application/vnd.ms-excel",
                            "filterQuery": "content.mimetype:\"application/vnd.ms-excel\"",
                            "count": 1,
                            "display": "Microsoft Excel"
                        },
                        {
                            "label": "video/mp4",
                            "filterQuery": "content.mimetype:\"video/mp4\"",
                            "count": 1,
                            "display": "MPEG4 Video"
                        }
                    ]
                }
            ]
        },
Example 3: You can also combine the pivots with flat facets. The way facets are done is by taking facetFields and giving them a label and then giving them a structure in how you want to combine them together. Similarly, in this example, we are defining the fields and giving them a label by which we want to arrange the results together.
{
   "query": {
      "query": "name:*" 
   },
   "facetFields": {
      "facets": [
         {"field": "content.mimetype", "label": "mimetype"},
         {"field": "SITE", "label": "site"},
         {"field": "TYPE", "label": "type"}
      ]
    }
}
Response: The result shows a facetField entry for each label. There's a bucket for type, site, and mimetype.
"context": {
            "facetsFields": [
                {
                    "label": "type",
                    "buckets": [
                        {
                            "label": "{http://www.alfresco.org/model/content/1.0}category",
                            "filterQuery": "TYPE:\"{http://www.alfresco.org/model/content/1.0}category\"",
                            "count": 335
                        }
                        ...
                        {
                            "label": "{http://www.alfresco.org/model/transfer/1.0}transferGroup",
                            "filterQuery": "TYPE:\"{http://www.alfresco.org/model/transfer/1.0}transferGroup\"",
                            "count": 1
                        }
                    ]
                },
                {
                    "label": "site",
                    "buckets": [
                        {
                            "label": "_REPOSITORY_",
                            "filterQuery": "SITE:\"_REPOSITORY_\"",
                            "count": 711
                        },
                        ...
                        {
                            "label": "surf-config",
                            "filterQuery": "SITE:\"surf-config\"",
                            "count": 2
                        }
                    ]
                },
                {
                    "label": "mimetype",
                    "buckets": [
                        {
                            "label": "text/plain",
                            "filterQuery": "content.mimetype:\"text/plain\"",
                            "count": 120,
                            "display": "Plain Text"
                        },
                        {
                            "label": "image/png",
                            "filterQuery": "content.mimetype:\"image/png\"",
                            "count": 38,
                            "display": "PNG Image"
                        },
                        ...
                        {
                            "label": "video/mp4",
                            "filterQuery": "content.mimetype:\"video/mp4\"",
                            "count": 1,
                            "display": "MPEG4 Video"
                        }
                    ]
                }
            ]
        },

mimetype()

mimetype() groups content.mimetype in the same way as is done for reporting and analytics version 1. It can only be used as a facetField and not as a part of pivot, as shown in the example below.

Example:

{
  "query": {
      "query": "name:*"
  },
  "includeRequest": true,
  "facetFormat": "V2",
  "facetQueries": [
     {"query": "content.size:[0 TO 102400]", "label": "small", "group": "size"},
     {"query": "content.size:[102400 TO 1048576]", "label": "medium", "group": "size"},
     {"query": "content.size:[1048576 TO 16777216]", "label": "large", "group": "size"}
  ],
  "facetFields": {"facets": [{"field": "mimetype()"}]}
}

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.