# Index Search and Pattern Search

> Searches for objects in a database are performed using indexes. As explained in the Indexes page, eXtremeDB provides a number of specialized types of index.

> ## Lookups

> Hash indexes (including `autoid`) and unique BTree indexes allow applications to perform quick find or lookup operations specifying a unique key value. The lookup will position directly to that object or return a not-found status code. But `nonunique` indexes require performing a search operation to create a `cursor` which is then used to iterate over the results of the search as described in the API links below.

> ## Searches

> The search operations, for B-Tree, Patricia, R-Tree, KD-Tree and Trigram indexes, are used whenever it is necessary to:

> - Establish a starting position in a sorted list with a known starting value and optionally retrieve subsequent results in ascending or descending sorted order.
> - Establish a starting position in a sorted list when only part of the starting value is known, find the closest match, and optionally retrieve subsequent results in ascending or descending sorted order.
> - Establish a starting position as above, iterate over the sorted list in ascending or descending sorted order until a lower or upper bound is reached, using a `compare()` method to determine when the range limit is reached.

> - Establish a starting position with a known starting value, iterate over the list to retrieve each duplicate, using a `compare()` method to determine when the last duplicate was retrieved.

> After positioning a cursor with an index search operation, or one of the cursor positioning functions (first, last, next, prev, etc.), the current object can then be read or modified.

> ## Pattern Search

> In addition to the search capabilities described in the previous section, eXtremeDB supports wildcard pattern matching ability. This is the capability to search tree index entries matching patterns specified with wildcard characters for single character and multiple character matches. By default, the question mark “?” will match any single character in the specified position within the pattern, and the asterisk “*” will match any combination of characters (including no characters) in that position. If a match on the characters “?” or “*” is desired, the wildcard characters themselves can be modified by specifying different characters in the pattern search policy (see below).

> For example, “G*e*” would return “Graves” and “Gorine”, while “Gr?ve*” would match “Graves”, “Grove”, “Grover” and so on... In this example, ‘*’ matches zero, one, or more characters, while ‘?’ matches exactly one character. Further, the pattern “G*E*” would match all uppercase entries like “GRAVES”, “GORINE”. However, because the standard compare functions used to match index values with search keys use case-sensitive compare functions, the case specified in the search pattern will affect the search results.

> The pattern search can be further controlled by information the eXtremeDB runtime obtains from a pattern policy that can be customized by the C or C++ application. Please use the C API link below for further details.

> ## Native language Search APIs

> The APIs and structures for performing searches are specific to the programming language used. Please use the links below to view detailed explanations and examples for your development environment:

> C | Index searches in C
> C++ | Index searches in C++
> Java | Index searches in Java
> Python | Index searches in Python
> C# | Index searches in C#