> ## Documentation Index
> Fetch the complete documentation index at: https://help.broadstripes.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search language basics

Broadstripes search uses a simple but powerful query language that lets you find exactly the records you need. This guide will teach you the fundamentals of how to construct search queries.

## Understanding search clause structure

Every search query is built from one or more **search clauses**. A search clause has three parts:

1. **Keyword** - The field you want to search (e.g., `city`, `department`, `status`)
2. **Operator** - How you want to compare the value (e.g., `=`, `!=`, `>`, `<`)
3. **Value** - What you're searching for (e.g., `Boston`, `Active`, `100`)

Here's a simple example:

```
city = Boston
```

In this search:

* `city` is the keyword (the field we're searching)
* `=` is the operator (we want exact matches)
* `Boston` is the value (what we're looking for)

This search will find all records where the city field equals "Boston".

## Working with spaces and quotation marks

### The basic rule

Keywords and values can only contain spaces if they're surrounded by quotation marks.

### When you need quotes

If your value contains spaces, wrap it in quotes:

```
worksite = "Factory A"
```

```
employer = "Acme Manufacturing Corp"
```

```
CustomField = "Full Time Employee"
```

Without quotes, the search won't work correctly because the system won't know where your value ends.

### When you don't need quotes

Single-word values don't need quotes:

```
department = Warehouse
```

```
city = Boston
```

```
status = Active
```

### Quote usage for keywords

The same rule applies to keywords. Most field names are single words and don't need quotes, but if you have a custom field with spaces in its name, you'll need to use quotes:

```
"Employment Status" = Active
```

```
"Job Category" = "Skilled Trades"
```

## Operator spacing

Operators work with or without spaces around them, but adding spaces makes your searches easier to read.

These two searches work identically:

```
city=Boston
```

```
city = Boston
```

**Best practice**: Use spaces around your operators for clarity.

Here are some common operators:

| Operator | Meaning                  |
| -------- | ------------------------ |
| `=`      | equals (exact match)     |
| `!=`     | not equals               |
| `>`      | greater than             |
| `<`      | less than                |
| `>=`     | greater than or equal to |
| `<=`     | less than or equal to    |
| `:`      | contains (partial match) |

**Examples with spacing:**

Find people 19 years old and older (based on their Birth Date and the current date):

```
age > 18
```

Find people hired on or after January 1, 2024:

```
HireDate >= 2024-01-01
```

```
lastname : Smith
```

```
status != Inactive
```

## Boolean searches with AND and OR

You can combine multiple search clauses using Boolean operators to create more powerful searches.

### AND is implied

When you write multiple clauses without an operator between them, Broadstripes treats them as AND:

```
city = Boston department = Sales
```

This finds records where the city is Boston **AND** the department is Sales.

### Using OR

Use `OR` (in uppercase) to find records matching any of your criteria:

```
city = Boston OR city = Cambridge
```

This finds records where the city is Boston **OR** Cambridge.

### Grouping with parentheses

Use parentheses to group clauses and control the order of evaluation. This is especially important when mixing AND and OR:

```
department = Sales (city = Boston OR city = Cambridge)
```

This finds people in the Sales department who are located in either Boston or Cambridge.

Without parentheses, the search might not work as expected. Compare these two searches:

```
department = Sales city = Boston OR city = Cambridge
```

This could be interpreted incorrectly. Always use parentheses to make your intent clear:

```
department = Sales (city = Boston OR city = Cambridge)
```

### More Boolean examples

Find leaders at multiple locations:

```
role = any (employer : "Big Shop" OR employer : "Small Shop")
```

Find people who need outreach (haven't been contacted recently OR have a filed grievance):

```
lastcontact < "90 days ago" OR GrievanceStatus = Filed
```

## Searching by date

Broadstripes provides flexible date searching, including support for natural language dates.

### Standard date format

You can search using standard date formats:

```
HireDate = 2024-01-15
```

```
HireDate >= "January 1, 2025"
```

```
"Hire Date" < 6/30/2025
```

### Natural language dates

Broadstripes understands natural language date expressions, which makes searches easier to write and maintain. Wrap these expressions in quotes:

```
CardSignedDate < "11 months ago"
```

```
lastcontact > "2 weeks ago"
```

```
HireDate >= "one year ago"
```

```
LastContact < "90 days ago"
```

### Common natural language patterns

Expressions like these are supported:

* `"yesterday"`
* `"last week"`
* `"last month"`
* `"2 weeks ago"`
* `"3 months ago"`
* `"one year ago"`
* `"90 days ago"`

### Date range examples

Find people who signed cards in the past month:

```
CardSignedDate >= "one month ago"
```

Find people who haven't been contacted in over 90 days:

```
lastcontact < "90 days ago"
```

Find people hired this year:

```
HireDate >= 2024-01-01
```

Find people whose membership expires soon:

```
MembershipExpires <= "60 days from now"
```

## Searching for multiple values

You can search for multiple values at once using parentheses. This is useful when you want to find records that match any of several options.

### Basic multi-value syntax

Put your values in parentheses, separated by commas:

```
city = (Boston, Cambridge, Somerville)
```

This finds all records where the city is Boston, Cambridge, OR Somerville.

### More examples

```
status = (Active, Pending)
```

```
department = (Sales, Marketing, "Customer Service")
```

```
state = (MA, NH, VT, ME)
```

Note that if any value in your list contains spaces, it still needs quotes.

### Learn more

Multi-value searches have additional features and options. For complete details, see the [Creating multi-value searches](https://help.broadstripes.com/docs/search/creating-multi-value-search) guide.

## Searching related records (sub-queries)

One of the most powerful features of Broadstripes search is the ability to search based on properties of related records. These are called **sub-query searches** or **relational searches**.

### The concept

Instead of searching for a specific value, you can search for records that have a relationship to other records matching certain criteria.

### Basic sub-query syntax

Use square brackets `[]` to create a sub-query:

```
employer = [state = MA]
```

This finds all people whose employer is located in Massachusetts. You're not searching for employers directly—you're finding people whose employer meets the condition inside the brackets.

### More examples

Find people who work for organizations in the healthcare industry:

```
employer = [industry = Healthcare]
```

Find people whose supervisor has a specific title:

```
supervisor = [title = "Department Manager"]
```

### Combining with other searches

You can combine sub-queries with regular searches:

```
city = Boston employer = [state = MA]
```

This finds people who live in Boston AND whose employer is in Massachusetts.

***

## Next steps

Now that you understand the basics of search syntax, you can start building more complex queries by:

* Combining Boolean operators for complex logic
* Using date searches to find time-sensitive records
* Exploring the full range of available keywords for your project

For more detailed documentation, visit the [Broadstripes Help Center](https://help.broadstripes.com).
