> For the complete documentation index, see [llms.txt](https://documentation.ajaxsearchpro.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.ajaxsearchpro.com/behavior/search-logic.md).

# Search logic (primary and secondary)

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

![](/files/gRDRI8gC4DlfXEu8oGVM)

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](/behavior/search-logic/search-logics-explained.md)

### 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](broken://pages/-L9jkL0axQfFUrEZ1mqf), 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                            |
