# SearchCondition

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Reference](https://developer.m-files.com/APIs/gRPC-API/Reference/index.md) > [Messages](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchCondition/

A structure that specifies a single search condition.

A condition compares the value of `expression`, evaluated for each object, with `value` using the
operator `type`. Common conditions:

| To find objects... | `expression` | `type` | `value` |
| --- | --- | --- | --- |
| that are not deleted | status value `STATUS_TYPE_IS_DELETED` | `CONDITION_TYPE_EQUAL` | Boolean `false` |
| of an object type | status value `STATUS_TYPE_OBJECT_TYPE` | `CONDITION_TYPE_EQUAL` | lookup, value list -11, item = object type ID |
| of a class | property value, `property_def` 100 | `CONDITION_TYPE_EQUAL` | lookup, value list 1, item = class ID |
| of any of several classes | property value, `property_def` 100 | `CONDITION_TYPE_EQUAL` | multi-select lookup of the class IDs |
| with an object ID | status value `STATUS_TYPE_OBJECT_ID` | `CONDITION_TYPE_EQUAL` | integer |
| whose title contains a text | property value, `property_def` 0 | `CONDITION_TYPE_CONTAINS` | text |
| that refer to a lookup item | property value of the lookup property | `CONDITION_TYPE_EQUAL` | lookup of the item |
| whose property is empty | property value | `CONDITION_TYPE_EQUAL` | the property's data type, `is_null_value` true |
| modified in the last 7 days | property value 21 with `DATA_FUNCTION_DAYS_FROM` | `CONDITION_TYPE_LESS_THAN_OR_EQUAL` | integer 7 |
| matching a full-text search | any field, `search_metadata` and/or `search_filedata` set | `CONDITION_TYPE_CONTAINS` | text |
| with a file name pattern | file value `FILE_VALUE_TYPE_FILE_NAME` | `CONDITION_TYPE_MATCHES_WILDCARD_PATTERN` | text such as `*.pdf` |

Property and value list IDs other than the built-in ones (0 Name or title, 20 Created, 21 Last
modified, 100 Class; value list 1 for classes, -11 for object types) differ between vaults: resolve
them by alias or GUID first. A condition the server cannot evaluate fails with "Invalid search
condition."

- **Full name:** `MFiles.SearchCondition`
- **Proto file:** [`mfiles/structs.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/structs.proto)

<a id="fields"></a>

## Fields

| Field | Type | Number | Description |
|---|---|---|---|
| <a id="f-expression"></a>`expression` | [`Expression`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.Expression/index.md) | 1 | The left side of the condition: what is evaluated for each object, such as a property value, a status value or any field (full-text search). |
| <a id="f-type"></a>`type` | [`ConditionType`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.ConditionType/index.md) | 2 | The comparison operator. |
| <a id="f-value"></a>`value` | [`TypedValue`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.TypedValue/index.md) | 3 | The right side of the condition: the value to compare with. Its data type must suit the expression, for example a lookup for a lookup property, Boolean for `STATUS_TYPE_IS_DELETED`. |

<a id="used-by-methods"></a>

## Used by methods

- [IRPCDataExport.SearchExportedObjects](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCDataExport/SearchExportedObjects/index.md): Searches objects in batches ordered by object ID, for paging through all objects that match.
- [IRPCObjectOperations.CountObjectVersionsMatchingConditions](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/CountObjectVersionsMatchingConditions/index.md): Counts the versions of an object that DestroyObjectVersionsByConditions would destroy with the same inputs, without destroying anything.
- [IRPCObjectOperations.DestroyObjectVersionsByConditions](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DestroyObjectVersionsByConditions/index.md): Destroys the old versions of an object that match search conditions, and returns how many were destroyed.
- [IRPCSearch.GetSearchHits](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetSearchHits/index.md): Finds the words of a text that a full-text search condition matches, for hit highlighting.
- [IRPCValueLists.SearchValueListItemsWithPermissions](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCValueLists/SearchValueListItemsWithPermissions/index.md): Searches the items of one value list or object type by item ID, name, owner, parent or deleted state.

<a id="used-in-fields"></a>

## Used in fields

- [`GroupingLevel.property_folder_filter`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.GroupingLevel/index.md#f-property_folder_filter): The conditions that limit the values (property folders) of this expression.
- [`LookupItemRequest.search_conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.LookupItemRequest/index.md#f-search_conditions): Item conditions, combined with AND, on the item pseudo properties 1-8 (for example 2 = name); see the [IRPCValueLists](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCValueLists/index.md) overview.
- [`NotificationRule.object_filter`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.NotificationRule/index.md#f-object_filter): The search conditions that an object must meet for the rule to apply, combined with AND. The built-in rules include a "not deleted" condition (`STATUS_TYPE_IS_DELETED` equal to false).
- [`PropertyDef.value_list_item_filter`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.PropertyDef/index.md#f-value_list_item_filter): A static filter on the items of `value_list`. The server applies it when this property is passed as `filtering_property_def` or `LookupItemRequest.property_def`; such conditions cannot be sent in `search_conditions` directly.
- [`SearchConditionArray.value`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchConditionArray/index.md#f-value): The conditions. All of them must match.
- [`SearchDef.filter_conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchDef/index.md#f-filter_conditions): The conditions that limit the object set of this search.
- [`StateConditions.search_conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.StateConditions/index.md#f-search_conditions): Manual criteria.
- [`StateTransition.trigger_criteria`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.StateTransition/index.md#f-trigger_criteria): The criteria for automatically triggered state transition.
- [`SearchExportedObjectsRequest.condition_array`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCDataExport/SearchExportedObjects/index.md#request): Search conditions, combined with AND. See [SearchCondition](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.SearchCondition/index.md) and [Search](https://developer.m-files.com/APIs/gRPC-API/concepts/search/index.md).
- [`DestroyObjectVersionsByConditionsRequest.conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/DestroyObjectVersionsByConditions/index.md#request): The conditions a version must match to be destroyed. Must not be empty.
- [`CountObjectVersionsMatchingConditionsRequest.conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCObjectOperations/CountObjectVersionsMatchingConditions/index.md#request): The conditions a version must match to be destroyed. Must not be empty.
- [`GetSearchHitsRequest.search_condition`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCSearch/GetSearchHits/index.md#request): The full-text search condition that specifies the search words (Represented by SearchCondition sturct).
- [`SearchValueListItemsWithPermissionsRequest.search_conditions`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCValueLists/SearchValueListItemsWithPermissions/index.md#request): Conditions on the item pseudo properties 1-8 (see the service overview), combined with AND. Empty returns all items, deleted ones included.
