> ## 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 area

> Search areas tell a FlexiLayout where to look for objects, using absolute coordinates or relations to other elements, offsets, and the Nearest property.

A **search area** is defined by a set of search constraints and relations. It tells the program where to look for the objects described by the elements.

Search areas are made up of one or more rectangles which need not have common boundaries, that is, search areas may be discontinuous.

A search area may be defined by absolute search constraints, that is, by coordinates, or by relative search constraints, that is, by relations to other elements.

When specifying relative search constraints, you can use any elements located above the described element in the FlexiLayout tree (the image object corresponding to this element can only be found by using information about the already found objects described by the elements higher up in the tree).

## Specify the absolute coordinates of a search area

An absolute search area is defined on the **Search Constraints** tab of the element's **Properties** dialog box.

For multi-page documents, you can select a range of pages on which to search for an element. You can specify the absolute local coordinates of a search area in the **Region** property.

## Exclude an element from the search area

The **Exclude regions of elements** property lets you exclude the region of an element's found hypothesis from the search area. If no hypothesis is found for the excluded element, this constraint does not affect the search area of the element.

<Note>
  An exception occurs when additional constraints are specified for some of the boundaries of the hypothesis for the excluded element in the **Advanced pre-search relations** pane. In this case, if the excluded element is not found, FlexiLayout Studio cuts out the rectangular search area of this element from the surrounding search area. For more information about internal rectangles, see [Fuzzy rectangle](/flexi-capture/fls/language/fuzzy-rect).
</Note>

## Recognize vertical text

For the **Currency**, **Date**, **Phone**, **Character String**, **Static Text**, and **Paragraph** elements, a **Search through vertical text** option is available, which recognizes both horizontally and vertically oriented text. The **Clockwise oriented** and **Counterclockwise oriented** options enable and disable the recognition of vertical text from top to bottom and from bottom to top respectively. These options are enabled by default and can be disabled only when **Search through vertical text** is selected.

## Specify a search area relative to another element

A relative search area is defined on the **Relations** tab of the element's **Properties** dialog box. To define a relative search area, specify a reference element relative to which the boundaries are defined, and specify the relations of type **Right of**, **Left of**, **Above**, and **Below** (the **Relations** property).

You can specify any number of search areas for any element. The boundaries of a search area may be specified relative to different reference elements. If no relative search area has been specified, the program will look for the object everywhere on the image.

Each of the search constraints specifies a half-plane. The intersection of the half-plane and the image produces a rectangular part of the search area. The intersection of all the search constraints with the image produces the search area of an element.

The boundaries of a search area can be specified more accurately by means of the **Element boundary** and **Offset** properties.

### The Element boundary property

The **Element boundary** property specifies a boundary of a search area relative to the top, bottom, left, or right boundary of an element. By default, this property is set to `<whole>`.

When calculating a relative search area, FlexiLayout Studio may fail to find the reference element specified in the **Reference element** property. The calculation therefore differs depending on whether the reference element is found.

If the reference element is optional and no objects on the image meet the conditions specified in the element, a null hypothesis is formulated. The region of this null hypothesis coincides with the rectangle that encloses the search area of the element.

If the reference element is found, the region of the hypothesis is built from the regions of the detected objects that participate in the hypothesis, and is located inside the search area of the element.

When the reference element is found and **Element boundary** is set to `<whole>`, a **Right of** constraint means "to the right of the right boundary of the reference element", a **Left of** constraint means "to the left of the left boundary of the reference element", and so on (that is, relative to the hypothesis).

When no hypothesis for the reference element is formulated, the element could be located anywhere in the search area of the reference element, but not outside it.

In that case, a **Right of** constraint means "to the right of any area where the hypotheses for the reference element could be located". Mathematically, this means "to the right of the left boundary of the search area of the reference element". Similarly, a **Left of** constraint means "to the left of the right boundary", a **Below** constraint means "below the top boundary", and an **Above** constraint means "above the bottom boundary".

If **Element boundary** is set to a specific value (**Left**, **Top**, **Right**, or **Bottom**), the search area is calculated relative to that boundary of the reference element's hypothesis, whether or not the hypothesis has been found. For example, for a non-found hypothesis, a **Right of** constraint with **Element boundary** set to **Right** means "to the right of the right boundary of the search area of the reference element".

### The Offset property

The **Offset** property shifts a boundary of the search area by a certain distance. A positive **Offset** value moves the boundary in the same direction as the **Relation** property specifies. A negative **Offset** value moves the boundary in the opposite direction.

For example, a FlexiLayout contains a **YourPlanetName** element of type **Static Text** that finds the YOUR PLANET NAME: field name on the image. The goal is to find the text entered in this field (in this case, "MARS (satellite Phobos)").

Create a **Planet** element of type **Character String** and specify a search area located to the right of the **YourPlanetName** element, that is, set the **Element boundary** property to **Right of**. The following figure shows the location of the search area:

<Frame>
  <img src="https://mintcdn.com/abbyy/lqYknuOmCa79141v/images/flexi-capture/fls/SearchArea_I.gif?s=dccbc554db58e2b83a577c8dfbce23f2" alt="Diagram of the search area located to the right of the YourPlanetName element" width="290" height="27" data-path="images/flexi-capture/fls/SearchArea_I.gif" />
</Frame>

Move the boundary of the search area to the right, that is, in the same direction as the **Right of** relation. To do this, select a positive **Offset** value, for example, 200. The following figure shows the new location of the boundary:

<Frame>
  <img src="https://mintcdn.com/abbyy/lqYknuOmCa79141v/images/flexi-capture/fls/SearchArea_II.gif?s=468f7adfa95f3d90fb1f2bc998decfbd" alt="Diagram of the search area boundary moved to the right by a positive Offset value" width="299" height="37" data-path="images/flexi-capture/fls/SearchArea_II.gif" />
</Frame>

Now move the boundary of the search area to the left, that is, in the direction opposite the **Right of** relation. To do this, select a negative **Offset** value, for example, -200. The following figure shows the new location of the boundary:

<Frame>
  <img src="https://mintcdn.com/abbyy/lqYknuOmCa79141v/images/flexi-capture/fls/SearchArea_III.gif?s=b06c160ef3ebe156d928f735dc447ba6" alt="Diagram of the search area boundary moved to the left by a negative Offset value" width="306" height="39" data-path="images/flexi-capture/fls/SearchArea_III.gif" />
</Frame>

## Select the element located closest to a certain object

The **Nearest** property tells FlexiLayout Studio that, all other things being equal, it must look for the hypothesis located closest to a certain element or point on the image. Specify the closest element, point, or coordinate axis in the **Nearest** property of the element.

## View a search area

When you edit relation properties or select a relation in the **Relations** table, the relation is visualized in the **Image** window. When you select several relations, their intersection is displayed. In **Reference layout** mode, you can also drag the offset boundary with the mouse directly in the image window to change the offset value.

When matching a FlexiLayout, FlexiLayout Studio first calculates the search area of the element using all the specified constraints. It then checks whether the image objects located in the search area have the same properties as the elements.

If matching the FlexiLayout finds the wrong object, you can see why by looking at the search area of the element.

To display the search area of an element after matching a FlexiLayout, right-click the hypothesis that corresponds to the element and select **Show Search Area** on the shortcut menu. The search area appears in the **Image** window.

## Related topics

* [Search constraints](/flexi-capture/fls/template/basic-constraints)
* [Relative search area](/flexi-capture/fls/template/relations)
* [Use instances of a Repeating Group as reference, excluded, or source elements](/flexi-capture/fls/template/select-repeatable-group)
* [Additional search constraints](/flexi-capture/fls/template/advanced-constraints)
