Configure Search
You can configure the project search page to show different filter controls on the left hand side by adding some properties to your project JSON descriptor. These controls ultimately feed into a Cloud CMS node API find
call that has the following structure:
{ "query": ... query block into MongoDB, "search": ... search block into Elastic Search }
The following customization block can be added to your project's JSON descriptor:
{
...,
"search": {
"showContentTypes": true,
"showAssociationTypes": true,
"showProperties": true,
"showCreatedBy": true,
"showCreationDateStart": true,
"showCreationDateEnd": true,
"showModifiedBy": true,
"showModificationDateStart": true,
"showModificationDateEnd": true,
"contentTypes": [],
"associationTypes": [],
"properties": [],
"searchTemplate": null
}
}
Configuration within User Interface
The user interface for Cloud CMS allows you to specify these settings per project. As such, each project can have a uniquely configured search mechanism.
The configuration is available from Project > Manage Project > Search.
Configuration within Cloud CMS administration console
The administration console is available for managers or owners of your tenant.
Example
Here is an example where we constrain the content types list and the set of available properties to filter by. We also hide some of the controls to simplify the search selection.
{
...,
"search": {
"showContentTypes": true,
"showAssociationTypes": false,
"showProperties": true,
"showCreatedBy": false,
"showCreationDateStart": false,
"showCreationDateEnd": false,
"showModifiedBy": false,
"showModificationDateStart": false,
"showModificationDateEnd": false,
"contentTypes": [
"my:article",
"my:press-release",
"my:news-item"
],
"properties": [
"title",
"description",
"body",
"author",
"rating"
]
}
}
Search Template
The searchTemplate
setting allows you to provide a Handlebars template that can be used to generate the search block that gets passed to the Elastic Search API. This search block should be in the Elastic Search DSL format.
By default, none is provided, and the following template is used:
{
"query_string": {
"query": ""
}
}
Where the following model is passed into the template processor:
{
"searchTerm": "",
"properties": []
}
And:
searchTerm
contains the full-text search string that the user is looking for.properties
is an optional array of dot-delimited schema properties that the end user has opted to search against.
You can therefore specify a custom search template in your project's search
block like this:
{
...,
"search": {
...,
"searchTemplate": "{'query_string': { 'query': '' } }"
}
}
When performing property-level searches, it is important to note that the default search template (shown above) includes the all
field as a last element in the field list. This sets things up so that Cloud CMS will find as many matches as possible. However, it will place your exact field matches first in the ordered result list.
This is good in terms of finding things but it isn't very precise. Some customers prefer to have an exact match on fields (where fuzzy "all" matches are excluded). To accomplish this, you can adjust the search template to something like this:
{
"query_string": {
"query": ""
}
}
Here, the all
field isn't included and the fields
array contains only the properties that your end users will have selected in the left-hand list.