# Search logic (primary and secondary)

```
Search Behavior -> Keyword Logic and Matching
```

![](https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2FwuV0xQxmzDSBXlCXJzVU%2Fimage.png?alt=media\&token=8ce953eb-22d0-4e69-a8b3-2a6e0871df3a)

There are **4 possible logics** to choose from:

* OR (default)
* OR with exact word matches
* AND
* AND with exact word matches

The default is "OR". For more information about the logics please read [search logics explained](https://documentation.ajaxsearchpro.com/behavior/search-logic/search-logics-explained)

### Primary vs Secondary keyword logic

Primary is the main logic, that the search uses by default. When there are not enough results to reach the [limit](https://documentation.ajaxsearchpro.com/behavior/broken-reference), the plugin automatically tries again with secondary keyword logic to fill the remaining results.

Always choose a more strict logic as the primary, and a less strict as secondary. Logic order by strictness (most strict first):

1. AND with exact keyword matches
2. AND
3. OR with exact keyword matches
4. OR

Recommended configurations:

| Primary keyword logic          | Secondary keyword logic       |
| ------------------------------ | ----------------------------- |
| AND with exact keyword matches | AND                           |
| OR with exact keyword matches  | OR                            |
| AND                            | OR with exact keyword matches |
| AND                            | OR                            |
| AND with exact keyword matches | OR with exact keyword matches |
| AND with exact keyword matches | OR                            |
