# tmuxp.cli.search.evaluate_match

- **Module:** tmuxp.cli.search
- **Package:** tmuxp
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/tmuxp/blob/153acdf6ff1268b14d3d03ed488f545a7123c8f1/src/tmuxp/cli/search.py#L676
- **Page:** https://libtmux.org/en/py/latest/workspace/reference/tmuxp-cli-search-evaluate_match/

```
tmuxp.cli.search.evaluate_match(fields: WorkspaceFields, patterns: list[SearchPattern], match_any: bool = False) -> tuple[bool, dict[str, list[str]]]
```

Evaluate if workspace fields match search patterns.

## Parameters

- `fields` (WorkspaceFields): Extracted workspace fields to search.
- `patterns` (list[SearchPattern]): Compiled search patterns.
- `match_any` (bool): If True, match if ANY pattern matches (OR logic).
If False, ALL patterns must match (AND logic). Default False.

## Returns

tuple[bool, dict[str, list[str]]]
    Tuple of (matched, {field_name: [matched_strings]}).
    The matches dict contains actual matched text for highlighting.

## Example

```python
>>> import re
>>> fields: WorkspaceFields = {
...     "name": "dev-project",
...     "path": "~/.tmuxp/dev-project.yaml",
...     "session_name": "development",
...     "windows": ["editor", "shell"],
...     "panes": ["vim", "git status"],
... }
```

## Example

Single pattern match:

```python
>>> pattern = SearchPattern(
...     fields=("name",),
...     raw="dev",
...     regex=re.compile("dev"),
... )
>>> matched, matches = evaluate_match(fields, [pattern])
>>> matched
True
>>> "name" in matches
True
```

## Example

AND logic (default) - all patterns must match:

```python
>>> p1 = SearchPattern(fields=("name",), raw="dev", regex=re.compile("dev"))
>>> p2 = SearchPattern(fields=("name",), raw="xyz", regex=re.compile("xyz"))
>>> matched, _ = evaluate_match(fields, [p1, p2], match_any=False)
>>> matched
False
```

## Example

OR logic - any pattern can match:

```python
>>> matched, _ = evaluate_match(fields, [p1, p2], match_any=True)
>>> matched
True
```

## Example

Window field search:

```python
>>> p_win = SearchPattern(
...     fields=("window",),
...     raw="editor",
...     regex=re.compile("editor"),
... )
>>> matched, matches = evaluate_match(fields, [p_win])
>>> matched
True
>>> "window" in matches
True
```
