# Searching and Filtering

You can use the search and CQL (Crisisworks Query Language) to perform anything from basic text based searches to advanced multi-field and multi-register queries. For detailed syntax and examples refer to the [CQL Reference](https://docs.cw.crisisworks.com/security-and-support/technical-reference/cql-reference).

## Filter/Counter Menu

The Filter/Counter menu contains some handy preconfigured queries which you can use to generate lists of items.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FJPIdjBvoYYe5vJBbeKyl%2Fimage.png?alt=media&#x26;token=c6be3922-a85b-4047-9eda-17de6e93dcd8" alt="" width="279"><figcaption><p>Filter/Counter menu</p></figcaption></figure>

Main and Assignments are shown at all times and indicates the number of items retrieved by the filter on the right. Urgent or overdue counters are indicated in red, all others are in blue. Open any filter/counter to view the list of matching items. The current query is displayed in the blue [search bar](#search-bar) which you can use to manually refine the set of items.

To view more filters, use the three dots icon <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FedbkJ3ZtZpLPNOrisQWu%2Fimage.png?alt=media&#x26;token=0ffa5a3e-b285-4e78-8a38-a0dcc5927d6b" alt="" data-size="line">. This will open the full set of available filters/counters menus which you can expand to show the full set of filters/counters.

The counter totals stay be up to date, however if you know items have very recently been added or changed and you suspect that the numbers are not up-to-date you can update them using the Refresh icon <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FCeudq4SXHYoPhIbSt8cr%2Fimage.png?alt=media&#x26;token=5418845e-0593-4d0d-baa2-f7e90465052e" alt="" data-size="line">.

## Register Filters

To query an individual register:

1. Open/expand the register to access the search box for that register.
2. Use the Filter icon  <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FR9an1QHSI2HlfXdJptvb%2Fimage.png?alt=media&#x26;token=801ecf46-f649-48a2-ab7d-8c46173e0286" alt="" data-size="line"> to open the search

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FCsIZpav35SIN7Y9nErYK%2Fimage.png?alt=media&#x26;token=9deae793-8ced-49fa-9b7b-85bfd1583d4c" alt=""><figcaption><p>The Register search is activated using the filter icon</p></figcaption></figure>

Register Search enables you to filter the lists with a combination of filters including text searching​ using the **Contains** field or by data field, for example Date, Name or ID​.

Contains works best for specific content such as reference numbers and names.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FHhRcdz0h74IFBeBZjjSV%2Fimage.png?alt=media&#x26;token=6745caa3-2044-4091-8bad-6bf201ff88d4" alt=""><figcaption><p>Filters menu for a register</p></figcaption></figure>

### Search bar

An alternative way to search is th Search bar is located in the Navigation bar. It also displays any currently applied filters. &#x20;

You can run a custom query  using the magnifying class icon <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FbxYRXGMORHSPStoaR8LE%2Fimage.png?alt=media&#x26;token=b769b287-0b24-43f5-9df8-88891901b71e" alt="" data-size="line">

{% hint style="info" %}
The Search bar will only search within the currently active Register.
{% endhint %}

To search, enter a CQL query into the white box that opens. The search field supports advanced querying (including wildcards and other search operators)​ across almost any field in the Register.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2F32zlD9zOb6X3OvnNhB9x%2Fimage.png?alt=media&#x26;token=7b5112de-015d-4dd1-bbf7-af73a2350f21" alt="" width="375"><figcaption><p>Search activated in the Navigation bar</p></figcaption></figure>

#### Help Reference <a href="#sharing-search-results" id="sharing-search-results"></a>

A help reference can be found in the search bar using the Help icon ![](https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FcctAKED5boUnxDyNTR30%2Fimage.png?alt=media\&token=61130507-93d1-4463-a6d3-3d9f987beda8) next to the magnifying glass icon.

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2Fq6lgDOoUa70gwkYmvSDy%2Fimage.png?alt=media&#x26;token=99462b7f-b32e-41ec-9bbe-54edfd2f24d3" alt=""><figcaption></figcaption></figure>

Once activated you can use the scroll bar to browse CQL query examples or use the link provided to return to this user guide. For advanced queries, please use the [CQL Reference](https://docs.cw.crisisworks.com/security-and-support/technical-reference/cql-reference).

<figure><img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FlebMLYXLIiPAq3cubYao%2Fimage.png?alt=media&#x26;token=9d867d83-2e63-4565-85f9-6879173b395a" alt=""><figcaption><p>Help reference for search bar</p></figcaption></figure>

### Sharing Search Results <a href="#sharing-search-results" id="sharing-search-results"></a>

Collaboration is made easy with the ability to share search results:

1. After conducting a search, copy the URL from the browser's address bar.
2. Share the URL via emails, documents, or bookmark it for future use.
3. Colleagues can click the shared link to access and resurrect the same search results.

By following these steps, users can efficiently navigate the system and retrieve the information they need.

## Clearing the search

Clearing the search is important so that your datagrid does not display unexpected results.

To clear a search, use the Clear <img src="https://3923904090-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy7IznbrPLUq6GJDDQDk%2Fuploads%2FPpj1h7y8R4IMA3175HaJ%2Fimage.png?alt=media&#x26;token=5014491b-c541-4b74-a0aa-b3d08e288a7f" alt="" data-size="line"> button. This will return you to the filter/counter menu.

## Search syntax and concepts <a href="#keyword-and-phrase-matching" id="keyword-and-phrase-matching"></a>

This section contains some of the types of searches you can perform on standard fields.

### Keyword and phrase matching <a href="#keyword-and-phrase-matching" id="keyword-and-phrase-matching"></a>

You can perform keyword queries on any field by entering the field as a prefix with a colon.  The Contains field provides a simple way of performing searches across all fields.&#x20;

Search for the word "clean" in all text fields:

`clean`

Use double quotes to search for records that contain phrases with spaces. For example, to search for the phrase "clean up" in all text fields:

`"clean up"`

### Searching within specific fields

You can reference specific fields by prefixing them with a colon.  Consult the technical specification for a full list of field names.

Search for records where the title must equal the word clean

`title:clean`

Wildcard searches are available using the \* symbol. This will search the title field where the first word is “water”. This would return results such as “water”, “waterfall”, “water-pump” or phrases such as “water is needed”.

`title:water*`

Search for records where the word water is anywhere within the title. This would return results with titles such as “I need water”, “Water is required”, “Property water is needed”

`title:*water*`

Search for an empty title field:

`title:none`

Search for whether the title field has a value

`title:any`

The \~ symbol performs SOUNDS LIKE searches. For example, in the contacts register a search such as the one below would return records that sound like “Smith” such as Smyth, Smith, Smath.

`lastName:~Smith`

### AND, OR and NOT searches <a href="#and-or-and-not-searches" id="and-or-and-not-searches"></a>

By default, when can combine multiple search terms they are combined with an “AND” logic — that is, the results will only contain records that match all search terms.

If you want to change this behaviour, you can explicitly specify the way the search should logical combine the terms by using the words AND, OR and NOT.

&#x20;This will return records that have both the words water and clean in the title field:

`title:*water* AND title:*clean*`

This will return records that have either the word water or clean in the title field:

`title:*water* OR title:*clean*`

Return items that have the word water in the title but not the word clean in the title:

`title:*water* NOT title:*clean*`

### “is” Searches <a href="#is-searches" id="is-searches"></a>

Shorthand search syntax has been developed to help simplify some common search queries.

Returns all active items:

`is:active`

Returns active and non-active items:

`is:any`

You can also use the NOT syntax to find all inactive items:

`NOT is:active`

### Using parentheses <a href="#using-parentheses" id="using-parentheses"></a>

Parentheses can be used to group together search terms in a logical way.

For contacts this search below will find records with the first name of Rick and last name of O’Shea OR any user:

`(firstName:Rick AND lastName:O'Shea) OR (isUser:true)`

### Testing if a field contains a value <a href="#testing-if-a-field-contains-a-value" id="testing-if-a-field-contains-a-value"></a>

You can test whether a field is set or unset using the following syntax.

To search for a field containing a value:

`fieldname:any`

to search for a field NOT containing a value

`fieldname:none`

You can also test whether a sub-record has been added for a register. For example in Recovery Case you can return items with no Private Assets:

`privateAssets:none`

You can also search for cases that have one or more private assets added.

`privateAssets:any`

### Operators and Wildcards

The search also supports operators and wildcards. ​

Some useful examples for beginners are:

| Operator | Usage                            | Examples                                                                   |
| -------- | -------------------------------- | -------------------------------------------------------------------------- |
| ?        | Substitutes a single character​  | <p>b?tter<code>​</code><br>returns 'butter', 'bitter', 'batter' etc​</p>   |
| \*       | Substitutes multiple characters​ | <p>clean\*<code>​</code><br>returns 'clean', 'cleans', 'cleaning' etc​</p> |
| \~       | Sounds like​                     | <p>\~smith<code>​</code><br>returns 'smith', 'smyth' etc​</p>              |
| none     | finds fields without data        | title:none                                                                 |
| any      | finds fields with any data       | title:any                                                                  |

### Textual Data and Complex Searches <a href="#textual-data-and-complex-searches" id="textual-data-and-complex-searches"></a>

For searches involving names or textual data, consider the following:

1. Use quotes for multi-word values.
2. Use "Sounds Like" searches by placing the tilde (`~`) character before the search term
3. Use asterisks (`*`) for wildcard searches (e.g., searching for names starting with a specific letter).
4. Implement boolean logic for complex searches using brackets `(` and `)`, as well as `AND`, `OR` and `NOT` keywords.

Examples using fields:

* `firstName:"Cameron Smith"` — will find a field containing a phrase
* `firstName:~April` — will find April and Apryl using a sounds-like search
* `firstName:Sc*` — finds all records beginning with `Sc`, such as Scott, Scot, Scod
* `firstName:Scott or firstName:April` — finds records with a first name of either Scott or April
* `(firstName:Ashley lastName:G*) OR (firstName:Apryl lastName:D*)` — looks for records Ashley G\* and Apryl D\*.

Soundex, phrase and boolean searches can also be performed on full text searches.

### Multi-register queries <a href="#textual-data-and-complex-searches" id="textual-data-and-complex-searches"></a>

You can perform a multi-register query on [registers with sub-items or related items](https://docs.cw.crisisworks.com/concepts-and-fundamentals/using-the-datagrid/viewing-items#embedded-and-related-items), however to do so you must do so via a field that contains a key for the other register. Consult the CQL technical documentation for further information on which registers and fields are available.

The query a different register, nest the query in brackets following the colon prefix of the key field.

Examples using multi-register queries:

* `relatedcase:(status:resolved)` — will only find related cases with a status of resolved
* `relatedcontacts:(id:123 status:inactive)` — will find related contacts with an ID of 123 and a status of Inactive
