# Search and conditions

Object search (`GET /v1/objects?q=`) and [rule](https://sigwise.ai/docs/guides/rules.md) conditions
share one small language for comparing signal values.

```
is_scammer >= 90 and trust_score < 1
buyer_intent = ready_to_buy, is_scammer < 20
```

## Grammar

A query is one or more **comparisons** joined by `and` (any case) or commas.
All of them must hold.

```
comparison := signal_key operator value
operator   := >= | <= | > | < | = | !=
```

`signal_key` is the key of one of your signals.

## Values by signal type

| Type | Value | Operators | Example |
|------|-------|-----------|---------|
| `noul` | A percentage. Values above 1 are read as percent, so `90` and `0.9` both mean 0.9. | all | `is_scammer >= 90` |
| `score` | The raw score, from 0 (first level) up. | all | `trust_score < 1` |
| `choice` | An option name, optionally quoted. | `=`, `!=` | `buyer_intent = ready_to_buy` |

Values are compared with the object's latest answer. An object with no answer
for a signal matches no comparison on it.

## Search versus rules

- **Search** is lenient. A `q` without any comparison operator is a substring
  search on object IDs and display names, and comparisons that don't parse or
  name an unknown signal are skipped.
- **Rules** are strict. A condition must parse completely, name existing
  signals and use operators their types support; otherwise creating the rule
  fails with a `400` that says what is wrong:

```json
{ "error": { "code": "bad_request", "message": "choice signal \"buyer_intent\" supports only = and !=" } }
```
