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

> Define where Advanced Designer looks for an element on a document image — using absolute coordinates or relations to anchor elements.

A **search area** is a region on the image where the program should look for objects corresponding to a specific element. It is calculated based on the conditions specified in the **Where to search** section of the **Properties** pane.

On semi-structured documents, some objects may appear in different locations on different documents, and so the program will not always be able to find them using absolute search areas. In this case, search areas can be defined relative to elements with permanent locations, or relative to fields that have already been found. There are also cases where an element can be detected without defining a search area (e.g. a Static Text element always containing some document-unique word can be detected based on that word alone) or by limiting the search area just to the first or the last page of a document.

## Specify a search area

<Steps>
  <Step title="Set up anchor elements">
    Create and set up so-called anchor elements. Any elements that have already been detected can be used as anchor elements, provided you can define some relations between them and the element you want the program to detect. Match the elements against your image using the **Match** command and make sure they are detected correctly.
  </Step>

  <Step title="Create the target element">
    Create an element corresponding to the image object you want to detect and specify its properties in the **What to search for** section.
  </Step>

  <Step title="Specify the search area">
    Specify search area in the **Where to search** section.

    1. In the **Search on** drop-down list, select **Whole Document** if you need to search the whole document, or **First Page** or **Last Page** if you need to restrict your search to the first or last pages. When specifying the search area in this manner, no anchor elements are required.
    2. If required, specify relations existing between the element to be detected and other elements or draw a search area directly on the image. You can specify search area boundaries in relation to other elements, exclude certain elements from the search area, or specify which element or page edge is nearest to the element to be detected.
  </Step>

  <Step title="Match the element">
    Click **Match** to make sure that your element can be detected correctly on all the documents.
  </Step>
</Steps>

## Specify a search area on the document image

In most cases you will specify a search area relative to the location of other search elements used as anchors. You can only use an element as an anchor if it was successfully found on the image, so you should first set up and match elements that will be used as anchors.

Click the **Draw on Image** button and draw a search area on your image. The search area should be close to or intersecting with the regions of the anchor elements. In the **Where to search** section, the **Right of**, **Below**, **Left of**, and **Above** properties will appear for the search area you have drawn, as well as coordinates to specify distances for those properties in relation to the search area and anchor elements. These properties are synchronized with the search area on the image. You can modify the search area at any time by either editing the area on the image or changing the relation properties in the **Properties** pane. When you select a relation in the **Properties** pane, the half-plane specified by this relation is highlighted on the document image.

Next, adjust relations for the anchor elements and the search area using the anchor element toolbar, which can be accessed by clicking an element's region:

<Frame>
  <img src="https://mintcdn.com/abbyy/Bmjdl5TjCaidPxKi/images/vantage/advanced-designer/ad_extractionrules_searcharea_tools.png?fit=max&auto=format&n=Bmjdl5TjCaidPxKi&q=85&s=6758acb61e42581bff05f6ac2bcb2a08" alt="Anchor element toolbar with directional arrows, delete-relations, nearest-to, and exclude tools for configuring a search area" style={{ width:"53%" }} width="236" height="40" data-path="images/vantage/advanced-designer/ad_extractionrules_searcharea_tools.png" />
</Frame>

* The directional arrow tools can be used to enable and disable object search relations relative to the element in the corresponding direction.
* The delete relations tool removes all relations set for the selected element.
* The nearest tool specifies that among all element hypotheses, the one nearest to the selected element should be considered if all other conditions are satisfied equally. When hypotheses are formulated, the object nearest to the selected element will be chosen. If this tool is used, the **Nearest to** property appears on the **Properties** pane. This property can be set for only one anchor element.
* The exclude tool excludes the selected element from the search area. It is used when an element inside the search area may be mistaken for the object being searched for. For example, if you are looking for a Character String element with a character set, a different Character String element with the same or similar character set can be chosen by mistake. To prevent this from happening, exclude the second element from the search area using the exclude tool. When you use this tool, the **Exclude** property appears in the **Properties** pane.

When you are finished setting up the search area, click the **Draw on Image** button to exit the Draw Search Area mode.

## Specify a search area in the Properties pane

These relations are equivalent to the ones configured using the anchor element toolbar described above. You can edit each relation separately.

If you switch on the Draw Search Area mode, the search area and the half-plane defined by the selected relation will be displayed on the document image. The search area will be synchronized with the relation properties.

### Right of, Below, Left of, Above, Exclude

In the **Where to search** section, click **Add** and select the relation type you wish to configure. In the dialog box that opens, select an anchor element. You can select any active element above the current element.

You can add multiple relations of each of these types.

You can modify the search area by changing the offset for the **Right of**, **Below**, **Left of**, and **Above** relations. A positive offset value means that the boundary will be moved in the same direction as specified in the relation. A negative offset value moves the boundary in the direction opposite to the direction specified in the relation. For example, a negative offset for the **Right of** relation will move the boundary to the left.

You can also select the element boundary from which the search area will be calculated. By default, the boundary is selected in such a way as not to include the anchor element in the search area (above the top boundary, below the bottom boundary, etc.). You can also calculate the search area from the opposite boundary of the anchor element (above the bottom boundary, below the top boundary, etc.) or from its center. To adjust this setting, click the boundary icon displayed for the appropriate relation.

#### Example

Suppose that you need to find a specific sequence of characters that is above some predefined static text on some documents and level with that static text on others. Setting the **Above** value to 0 will not have the search area consider elements level with the static text, meaning that your element will not be in the search area on some images:

<Frame>
  <img src="https://mintcdn.com/abbyy/Bmjdl5TjCaidPxKi/images/vantage/advanced-designer/ad_extractionrules_searcharea_example1_2.png?fit=max&auto=format&n=Bmjdl5TjCaidPxKi&q=85&s=3c2ad7e681fe3b97ddd25952aa198303" alt="Search area with Above value 0, excluding the area level with the static text" style={{ width:"24%" }} width="164" height="64" data-path="images/vantage/advanced-designer/ad_extractionrules_searcharea_example1_2.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/Bmjdl5TjCaidPxKi/images/vantage/advanced-designer/ad_extractionrules_searcharea_example1.png?fit=max&auto=format&n=Bmjdl5TjCaidPxKi&q=85&s=b034619b9513a6ce2d067686338d7c9a" alt="Document image where the target element falls outside the search area defined by Above 0" style={{ width:"21%" }} width="164" height="64" data-path="images/vantage/advanced-designer/ad_extractionrules_searcharea_example1.png" />
</Frame>

However, setting the **Above** value to -50 or clicking the boundary icon and selecting the **Bottom Boundary of Region** will include both the area level with the static text and the area above it, which guarantees that your element will be inside the search area on all images:

<Frame>
  <img src="https://mintcdn.com/abbyy/Bmjdl5TjCaidPxKi/images/vantage/advanced-designer/ad_extractionrules_searcharea_example2_2.png?fit=max&auto=format&n=Bmjdl5TjCaidPxKi&q=85&s=a9dcd91272605f5aca5c99d08715152e" alt="Search area expanded by setting Above to -50 to include both the area above and level with the static text" style={{ width:"26%" }} width="171" height="66" data-path="images/vantage/advanced-designer/ad_extractionrules_searcharea_example2_2.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/abbyy/Bmjdl5TjCaidPxKi/images/vantage/advanced-designer/ad_extractionrules_searcharea_example2.png?fit=max&auto=format&n=Bmjdl5TjCaidPxKi&q=85&s=cc666f6345949c776ef64e986d1226a3" alt="Document image where the target element correctly falls inside the expanded search area on all images" style={{ width:"25%" }} width="171" height="66" data-path="images/vantage/advanced-designer/ad_extractionrules_searcharea_example2.png" />
</Frame>

### Nearest to

When setting this relation in the **Properties** pane, you can select either a search element or one of the page edges as an anchor. This is the only relation that you can set for the first element in the tree. You can add only one relation of this type. You cannot add this relation for Group and Repeating Group elements, but you can add it for child elements of a group or a repeating group.

### Use a Repeating Group element as an anchor element

When you select an anchor element for a relation, you will see that Repeating Group elements and their child elements are always grayed out. However, you can use these elements as anchor elements. To set up a relation with a Repeating Group element, click the edit dropdown icon to the right of the element name and select the instance that will serve as an anchor element. You can specify the last found instance, all completed instances or an instance with a certain number.

## Edit and delete relations

You can change the anchor element for any existing relation by double-clicking the relation on the **Properties** pane. The offset and boundary settings will be preserved.

Existing relations can be deleted both using the anchor element pane and the delete button next to the appropriate property in **Properties** pane.

To delete a search area, click the delete relations icon on the search area. Alternatively, select **Whole Document**, **First Page**, or **Last Page** in the **Search on** property.
