> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter Objects

> Filter\_Objects module utilities and functionality.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/filter_objects.py)

## [IncomingQuery](/sdk/python/references/filter_objects)

```python theme={null}
class IncomingQuery()
```

Represents an incoming query with its components.

**Attributes**:

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| `query`      | *str*  | The query string.                                    |
| `operator`   | *str*  | The operator used in the query.                      |
| `exactMatch` | *bool* | Indicates whether the query requires an exact match. |

#### \_\_init\_\_

```python theme={null}
def __init__(query: str, operator: str, exactMatch: bool)
```

Initialize an [IncomingQuery](/sdk/python/references/filter_objects) object.

**Arguments**:

| Name         | Type   | Description                                          |
| ------------ | ------ | ---------------------------------------------------- |
| `query`      | *str*  | The query string.                                    |
| `operator`   | *str*  | The operator used in the query.                      |
| `exactMatch` | *bool* | Indicates whether the query requires an exact match. |

## [QueryObject](/sdk/python/references/filter_objects)

```python theme={null}
class QueryObject()
```

Represents a query object with its components.

**Attributes**:

| Name    | Type                                                    | Description                 |
| ------- | ------------------------------------------------------- | --------------------------- |
| `id`    | *str*                                                   | The ID of the query object. |
| `query` | *[RuleGroupType](/sdk/python/references/models/prompt)* | The query object.           |

#### parse\_incoming\_query

```python theme={null}
def parse_incoming_query(incoming_query: str) -> List[RuleType]
```

Parses an incoming query string into a list of [RuleType](/sdk/python/references/models/prompt) objects.

**Arguments**:

| Name            | Type  | Description                |
| --------------- | ----- | -------------------------- |
| `incomingQuery` | *str* | The incoming query string. |

**Returns**:

| Name                                                     | Description                 |
| -------------------------------------------------------- | --------------------------- |
| `List[[RuleType](/sdk/python/references/models/prompt)]` | A list of RuleType objects. |

#### evaluate\_rule\_group

```python theme={null}
def evaluate_rule_group(rule_group: RuleGroupType,
                        incoming_query_rules: List[RuleType]) -> bool
```

Evaluates a rule group against incoming query rules.

**Arguments**:

| Name                 | Type                                                      | Description                 |
| -------------------- | --------------------------------------------------------- | --------------------------- |
| `ruleGroup`          | *[RuleGroupType](/sdk/python/references/models/prompt)*   | The rule group to evaluate. |
| `incomingQueryRules` | *List\[[RuleType](/sdk/python/references/models/prompt)]* | The incoming query rules.   |

**Returns**:

| Name   | Description                                      |
| ------ | ------------------------------------------------ |
| `bool` | True if the rule group matches, False otherwise. |

#### check\_operator\_match

```python theme={null}
def check_operator_match(field_rule: RuleType,
                         field_incoming_rule: RuleType) -> bool
```

Checks if the operator between two rules matches.

**Arguments**:

| Name                | Type                                               | Description                 |
| ------------------- | -------------------------------------------------- | --------------------------- |
| `fieldRule`         | *[RuleType](/sdk/python/references/models/prompt)* | The rule with the operator. |
| `fieldIncomingRule` | *[RuleType](/sdk/python/references/models/prompt)* | The incoming rule.          |

**Returns**:

| Name   | Description                                    |
| ------ | ---------------------------------------------- |
| `bool` | True if the operator matches, False otherwise. |

#### condition\_met

```python theme={null}
def condition_met(field_rule: RuleType, field_incoming_rule: RuleType) -> bool
```

Checks if the condition between two rules is met.

**Arguments**:

| Name                | Type                                               | Description                  |
| ------------------- | -------------------------------------------------- | ---------------------------- |
| `fieldRule`         | *[RuleType](/sdk/python/references/models/prompt)* | The rule with the condition. |
| `fieldIncomingRule` | *[RuleType](/sdk/python/references/models/prompt)* | The incoming rule.           |

**Returns**:

| Name   | Description                                    |
| ------ | ---------------------------------------------- |
| `bool` | True if the condition is met, False otherwise. |

#### find\_best\_match

```python theme={null}
def find_best_match(objects: List[QueryObject],
                    incoming_query: IncomingQuery) -> Optional[QueryObject]
```

Finds the best match for the incoming query among the list of objects.

**Arguments**:

| Name            | Type                                                          | Description                            |
| --------------- | ------------------------------------------------------------- | -------------------------------------- |
| `objects`       | *List\[[QueryObject](/sdk/python/references/filter_objects)]* | The list of objects to search through. |
| `incomingQuery` | *[IncomingQuery](/sdk/python/references/filter_objects)*      | The incoming query to match against.   |

**Returns**:

| Name                                                             | Description                                                          |
| ---------------------------------------------------------------- | -------------------------------------------------------------------- |
| `Optional[[QueryObject](/sdk/python/references/filter_objects)]` | The best match for the incoming query, or None if no match is found. |

#### find\_all\_matches

```python theme={null}
def find_all_matches(objects: List[QueryObject],
                     incoming_query: IncomingQuery) -> List[QueryObject]
```

Finds all matches for the incoming query among the list of objects.

**Arguments**:

| Name             | Type                                                          | Description                            |
| ---------------- | ------------------------------------------------------------- | -------------------------------------- |
| `objects`        | *List\[[QueryObject](/sdk/python/references/filter_objects)]* | The list of objects to search through. |
| `incoming_query` | *[IncomingQuery](/sdk/python/references/filter_objects)*      | The incoming query to match against.   |

**Returns**:

| Name                                                         | Description                                   |
| ------------------------------------------------------------ | --------------------------------------------- |
| `List[[QueryObject](/sdk/python/references/filter_objects)]` | A list of all matches for the incoming query. |
