Advanced Filter (JSON)
Overview
The Content Widget and the Content Listing Block (Filter type) now both support an Advanced Filter option. This Advanced Filter option is presented as a JSON Text field.
The Advanced Filter allows you to filter on one of more specific taxonomy values, as well as content type.
E.g.
- Content Type (File, Folder)
- File Extension
- Directory (optionally include content from sub directories)
It also allows you to specify more advanced AND/OR clauses (by specifying All or Any) as well as use nested (group) clauses, which allow you to accurately define which content you want to be displayed.
This Advanced Filter option is presented as a JSON Text field, of which there are examples in this document to help illustrate its usage.
Content Widget
![](https://files.readme.io/97959fe-image.png)
Content Listing Block
![](https://files.readme.io/ab9ebc5-image.png)
Root Node
The advanced filter root node is a "Filter". The root "Filter" is actually a Filter Group, meaning that it can contain multiple filter items, or nested filter groups. So, in the root filter node, you can choose to return documents that match all or any of the filter items within it.
Filter Group
A filter group contains
- Mode (All or Any)
- Items (a collection of Filter Items)
- Groups (a collection of Filter Groups)
This allows you to build up complex filters, made up of a combination of filters, groups and modes (similar to the Personas query builder).
Filter Item
A filter item can be used to filter on either
- Taxonomy (Default or Custom)
- TypeFacet (Content Type)
For a filter item, if more than one of the Taxonomy or TypeFacet properties are specified, then they are all evaluated together - and all of them must be matched by documents that are returned.
Examples
Example 1
Show me content which is in the "Engineering" site AND in the directory "Workplace Search Testing/"
{
"Filter": {
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "Engineering"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Value": "Workplace Search Testing/"
}
}
}
]
}
}
This will only show content within that directory, and not in subdirectories. It will also list both folders and files.
Example 2
Show me content which is in the "Engineering" site AND in the directory "Workplace Search Testing/" including subdirectories
For this, you could change "Example 1" so that the Directory filter use a "StartsWith" operator (rather than an "Equals" operator which is what it uses by default if one is not specified).
For example, if items have a Directory value of any of the following:
- Workplace Search Testing/
- Workplace Search Testing/A subdirectory/
- Workplace Search Testing/A subdirectory/Another subdirectory/
Then they would all be returned from a "StartsWith" "Workplace Search Testing/" filter.
{
"Filter": {
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "Engineering"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Operator": "StartsWith",
"Value": "Workplace Search Testing/"
}
}
}
]
}
}
But, this will show both files and folders, which is probably not what you would want to do if you are including all files in all subdirectories.
Example 3
Show me only files which are in the "Engineering" site AND in the directory "Workplace Search Testing/" including subdirectories
For this, a filter item does not have to just be of type "Taxonomy" and can instead be of type "TypeFacet", which correspond to the different "Content Types" that you see in the General Search results page filters.
{
"Filter": {
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "Engineering"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Operator": "StartsWith",
"Value": "Workplace Search Testing/"
}
}
},
{
"TypeFacet": {
"Value": "Site Drive File"
}
}
]
}
}
Example 4
I want to see files from 2x different sites and specifically files from 2x folders (and subdirectories) within those sites
I want wanting to see files from Any of the following sites
- Engineering
- SharePoint Testing
For the "Engineering" site, I only want to see content that is in the "Workplace Search Testing" directory (and its subdirectories) and content that is a "Site Drive File" (not folders).
So, for Engineering, show me content that meets All of the following criteria:
- Site = "Engineering"
- Directory StartsWith "Workplace Search Testing/"
- TypeFacet = "Site Drive File"
This results in a root filter (group) of mode "Any" containing with 2x groups (1 per each site). And for each group (site) the mode is "All".
{
"Filter": {
"Mode": "Any",
"Groups":[
{
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "Engineering"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Operator": "StartsWith",
"Value": "Workplace Search Testing/"
}
}
},
{
"TypeFacet": {
"Value": "Site Drive File"
}
}
]
},
{
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "SharePoint Testing"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Operator": "StartsWith",
"Value": "Christine's Folder/"
}
}
},
{
"TypeFacet": {
"Value": "Site Drive File"
}
}
]
}
]
}
}
Example 5
I want to see:
- "Site Drive items from the "Engineering" site which are in the "Workplace Search Testing" directory (or subdirectory of)
Or
- List items from the "Countries" list in the "SharePoint Testing" site, which have a population greater than 300 million
{
"Filter": {
"Mode": "Any",
"Groups":[
{
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "Engineering"
}
}
},
{
"Taxonomy": {
"Name": "Directory",
"Text": {
"Operator": "StartsWith",
"Value": "Workplace Search Testing/"
}
}
},
{
"TypeFacet": {
"Value": "Site Drive File"
}
}
]
},
{
"Mode": "All",
"Items": [
{
"Taxonomy": {
"Name": "Site",
"Text": {
"Value": "SharePoint Testing"
}
}
},
{
"Taxonomy": {
"Name": "Site List",
"Text": {
"Value": "Countries"
}
}
},
{
"Taxonomy": {
"Name": "Population",
"Number": {
"Operator": "GreaterThan",
"Value": 300000000
}
}
}
]
}
]
}
}
Here is what the Countries list contains:
And can see that only the 3x countries with a population greater than 300 million are returned.
Limitations
It is currently only possible to use the Advanced Filter to filter on the Standard or Custom (associated with List Items) taxonomy values.
There is actually a lot more data stored in the ELS index. For example, you can see the Last Updated Date in search results. But, it cannot currently be filtered using the Advanced Filter.
So, some scenarios are not currently possible, such as:
- Show me files from a particular site and folder which have a LastUpdatedDate greater than 1 week ago
Updated 3 months ago