# SearchContext

> The search context includes all the data necessary to perform a query. It allows the full customization of how a query may be performed.

## Definition

* **Type:** Class
* **Namespace:** [UnityEditor.Search](/engine/6000.6/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable), [ISerializationCallbackReceiver](/engine/6000.6/script-reference/unityengine/iserializationcallbackreceiver.md)

```csharp
public class SearchContext : IDisposable, ISerializationCallbackReceiver
```

## Constructors

| Constructor                                                                                                                                                                                                                                                                      | Description                   |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- |
| [SearchContext(System.Collections.Generic.IEnumerable\{UnityEditor.Search.SearchProvider})](/engine/6000.6/script-reference/unityeditor/search/searchcontext/ctor.md#searchcontext\(ienumerablesearchprovider\))                                                                 | Creates a new search context. |
| [SearchContext(System.Collections.Generic.IEnumerable\{UnityEditor.Search.SearchProvider},System.String)](/engine/6000.6/script-reference/unityeditor/search/searchcontext/ctor.md#searchcontext\(ienumerablesearchprovider-string\))                                            | Creates a new search context. |
| [SearchContext(System.Collections.Generic.IEnumerable\{UnityEditor.Search.SearchProvider},System.String,UnityEditor.Search.SearchFlags)](/engine/6000.6/script-reference/unityeditor/search/searchcontext/ctor.md#searchcontext\(ienumerablesearchprovider-string-searchflags\)) | Creates a new search context. |

## Properties

| Property                                                                                                   | Description                                                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [empty](/engine/6000.6/script-reference/unityeditor/search/searchcontext/empty.md)                         | Indicates of the search query is empty. This exclude the search filter id. In example if the search text is `h: `, then this property will still return true. |
| [filterId](/engine/6000.6/script-reference/unityeditor/search/searchcontext/filterid.md)                   | Explicit filter ID. Usually it is the first search token like h:, p: to do an explicit search for a given search provider. Can be null.                       |
| [options](/engine/6000.6/script-reference/unityeditor/search/searchcontext/options.md)                     | Search context options.                                                                                                                                       |
| [progressId](/engine/6000.6/script-reference/unityeditor/search/searchcontext/progressid.md)               | Progress handle to display the progress bar for the search currently in progress.                                                                             |
| [providers](/engine/6000.6/script-reference/unityeditor/search/searchcontext/providers.md)                 | Which search providers are active for this particular context.                                                                                                |
| [searchInProgress](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchinprogress.md)   | Indicates if an asynchronous search is currently in progress for this context.                                                                                |
| [searchPhrase](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchphrase.md)           | Returns a phrase that contains only words separated by spaces.                                                                                                |
| [searchQuery](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchquery.md)             | Processed search query (no filterId, no textFilters).                                                                                                         |
| [searchQueryOffset](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchqueryoffset.md) | Character offset of the processed search query in the raw search text.                                                                                        |
| [searchText](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchtext.md)               | Raw search text (what is in the Search text box).                                                                                                             |
| [searchView](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchview.md)               | The search view presenting the search results.                                                                                                                |
| [searchWords](/engine/6000.6/script-reference/unityeditor/search/searchcontext/searchwords.md)             | Search query tokenized by words. All text filters are discarded and all words are in lowercase.                                                               |
| [selection](/engine/6000.6/script-reference/unityeditor/search/searchcontext/selection.md)                 | Returns the search result selection if any.                                                                                                                   |
| [textFilters](/engine/6000.6/script-reference/unityeditor/search/searchcontext/textfilters.md)             | All tokens containing a colon (':').                                                                                                                          |
| [wantsMore](/engine/6000.6/script-reference/unityeditor/search/searchcontext/wantsmore.md)                 | Indicates if the search should return all the results instead of only the most relevant.                                                                      |

## Methods

| Method                                                                                                           | Description                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [AddSearchQueryError](/engine/6000.6/script-reference/unityeditor/search/searchcontext/addsearchqueryerror.md)   | Adds a new query error on this context.                                                                                        |
| [AddSearchQueryErrors](/engine/6000.6/script-reference/unityeditor/search/searchcontext/addsearchqueryerrors.md) | Adds new query errors on this context.                                                                                         |
| [Dispose](/engine/6000.6/script-reference/unityeditor/search/searchcontext/dispose.md)                           | Dispose of the Search Context.                                                                                                 |
| [IsEnabled](/engine/6000.6/script-reference/unityeditor/search/searchcontext/isenabled.md)                       | Checks if a search provider is available to process a query.                                                                   |
| [SetFilter](/engine/6000.6/script-reference/unityeditor/search/searchcontext/setfilter.md)                       | Enables or disables a single search provider. A disabled search provider won't be asked to provide items to resolve the query. |

## Events

| Member                                                                                                     | Description                                                   |
| ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [asyncItemReceived](/engine/6000.6/script-reference/unityeditor/search/searchcontext/asyncitemreceived.md) | This event is used to receive any asynchronous search result. |
| [sessionEnded](/engine/6000.6/script-reference/unityeditor/search/searchcontext/sessionended.md)           | Invoked when a Search has ended.                              |
| [sessionStarted](/engine/6000.6/script-reference/unityeditor/search/searchcontext/sessionstarted.md)       | Invoked when a Search is started.                             |
