(Click to open topic with navigation)
By default, there is no filter applied on any DataView page when it loads. The filter functionality more or less filters out items so that only those that match a certain criteria display. For example, a user can go to the Node Management page and see a list of all nodes. However, maybe the user only wants to see nodes that have a status of "Down." The user can do a search (which is essentially a filter) for nodes that are "Down" so that only those nodes display in the list.
You can configure the DataviewConfig.groovy file so that a default filter is applied to a page when it loads. Filtering uses a syntax that allows direct queries on the underlying MongoDB in MWS. Filters filter on the data contained in the MongoDB.
For information about MongoDB advanced queries, see the MongoDB documentation. For information about querying MWS, see their Resource documentation.
To configure the default filter
nodes = """{
"sort" : {"${DV_SORT_SORT}":[{"name":"ASC"}]},
"page" : {"${DV_PAGE_NUMBER}":0, "${DV_PAGE_COUNT}":20},
"filter" : "{}",
...
nodes = """{
"sort" : {"${DV_SORT_SORT}":[{"name":"ASC"}]},
"page" : {"${DV_PAGE_NUMBER}":0, "${DV_PAGE_COUNT}":20},
"filter" : "{
"query": {
"states.state": {
"$regex": "down",
"$options": "i"
}
}
}",
...
Make sure that the column you sort by is marked as filterable. The "${DV_FILTERABLE_KEY}" value should be set to 1 (true). For example:
nodes = """{
"sort" : {"${DV_SORT_SORT}":[{"states.state":"ASC"}]},
"page" : {"${DV_PAGE_NUMBER}":0, "${DV_PAGE_COUNT}":20},
"filter" : "{}",
"data" : {
"view":[
{"${DV_ID_KEY}": "name", "${DV_TITLE_KEY}": "Name", "${DV_VISIBLE_KEY}": 1, "${DV_SORTABLE_KEY}": 1, "${DV_FILTERABLE_KEY}": 1, "${DV_TYPE_KEY}": "${DV_STRING_TYPE}"},
{"${DV_ID_KEY}": "state", "${DV_TITLE_KEY}": "Status", "${DV_VISIBLE_KEY}": 1, "${DV_SORTABLE_KEY}": 1, "${DV_FILTERABLE_KEY}": 1, "${DV_TYPE_KEY}": "${DV_STRING_TYPE}", "${DV_DBKEY_KEY}": "states.state"},
...
For more information, see Making columns filterable.
job = """{
"sort" : {"${DV_SORT_SORT}":[{"name":"ASC"}]},
"page" : {"${DV_PAGE_NUMBER}":0, "${DV_PAGE_COUNT}":20},
"filter" : "{
"facets": [
{
"caption": "user contains admin",
"query": {
"user": {
"$regex": "admin",
"$options": "i"
}
}
},
{
"caption": "status contains scheduled",
"query": {
"status": {
"$regex": "scheduled",
"$options": "i"
}
}
}
]
}
...
Your changes should update automatically. However, if you see that your changes have not taken effect, it is recommended that you restart Tomcat.
Related topics