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

# Search Constraints

> Understanding how search regions are formed using element properties and search conditions.

An element's search region is formed using element properties set in the **Where to search** section and conditions set in the **Search Conditions** section. Before the properties and conditions are applied, the search area coincides with the page rectangle. First, the program applies element properties to the area. Next, the program applies additional restrictions set in the **Search Conditions** section.

The following types of constraint can be set in the **Search Conditions** section:

1. The search area can be limited to a rectangle (`Rect` variable), to a region (i.e. a continuous array of rectangles – `Region` variable), or to an array of rectangles which, in the general case, need not be continuous (`RectArray` variable). This type of constraint is set using the `RestrictSearchArea` function and by specifying a parameter of the corresponding type. Any expressions which return values of the required type can be specified as parameters.
2. The search area can be limited to a half-plane located to the left of, to the right of, above, or below a particular point. Such constraints are set using the Leftof, Rightof, Above, and Below functions.
3. Sometimes you may wish to set constraints for an element boundary. For example, it may be known beforehand that the left boundary of an element is always located in the left-hand part of the image, whereas the right boundary may stretch indefinitely to the right. The FlexiLayout language allows you to set such constraints at the stage of calculating the search area, thereby narrowing the range of possible hypotheses for an element. Such constraints are set using the `LeftBound`, `RightBound`, `topBound`, and `BottomBound` functions and the operators `>` and `<`. The `LeftBound` and `RightBound` functions are used to access the left and right boundaries of the search area, and the `topBound` and `BottomBound` functions are used to access the top and bottom boundaries respectively.
4. You can set search constraints by excluding a rectangle, an array of rectangles, a hypothesis etc. from the search area. This can be done by using the `Exclude`, `ExcludeRect`, and `ExcludeSet` functions.

You can specify any number of search constraints of the above types in the **Search Conditions** section. Each constraint will create a region on the image. All the regions created by the constraints will be intersected.

Additionally, the calculated search area for the element will be intersected with the search area for the Group element of which this element is a member.
