# Class SearchService

Allows searching for features by text phrase.

#### Hierarchy (view full)

- InitializableBase
  - SearchService

#####
Index

### Constructors

constructor

### Properties

_handles
@eventTypes
providers

### Accessors

failureMode
isDestroyed
isInitialized

### Methods

_getSerializableProperties
_initializableChildCollections
_initializeChildren
_onDestroy
_onInitialize
_postInitialize
_toPropertyDef
assignProperties
assignPropertiesAsync
count
destroy
finishAssignProperties
getDefault
getDefaults
getSerializableProperties
initialize
isSupported
search
suggest
toJSON

##
Constructors

### `Abstract` constructor

- new SearchService(...args): SearchService

- #### Parameters

  - `Rest`...args: [_properties?: InitializableBaseProperties]

  #### Returns SearchService

  Inherited from InitializableBase.constructor

##
Properties

### `Protected` `Readonly`_handles

_handles: Handles<unknown, ResourceHandle>

Inherited from InitializableBase._handles

### @eventTypes

@eventTypes: InitializableBaseEvents

#### Deprecated

Do not directly reference this property. Use EventNames and EventTypes helpers from @arcgis/core/Evented.

Inherited from InitializableBase.@eventTypes

### `Readonly` providers

providers: Collection<SearchProvider> = ...

Search providers that implement the search functionality. The collection is initially populated with built-in Geocortex providers, however providers can be added or removed. The order is significant -- the first registered provider that is able to handle a given data/FeatureSource!FeatureSource will be used for that source (see tasks/search/SearchProvider!SearchProvider.isSupported).

##
Accessors

### failureMode

- get failureMode(): FailureMode

- Determines how a parent object should handle initialization failure in this object. The default is "warn".

  - `"error"`: support/InitializeError!InitializeError is thrown.
  - `"warn"`: Message is logged and support/InitializableBase!InitializeWarningEvent is raised.
  - `"ignore"`: support/InitializableBase!InitializeWarningEvent is raised.

  #### Returns FailureMode

  Inherited from InitializableBase.failureMode

- set failureMode(value): void

- #### Parameters

  - value: FailureMode

  #### Returns void

  Inherited from InitializableBase.failureMode

### isDestroyed

- get isDestroyed(): boolean

- See support/InitializableBase!Initializable.isDestroyed.

  #### Returns boolean

  Inherited from InitializableBase.isDestroyed

### isInitialized

- get isInitialized(): boolean

- See support/InitializableBase!Initializable.isInitialized.

  #### Returns boolean

  Inherited from InitializableBase.isInitialized

##
Methods

### `Protected`_getSerializableProperties

- _getSerializableProperties(): PropertyDefs<InitializableBaseProperties>

- The property keys and their metadata that are used to implement serializing and deserializing the class instance.

  #### Returns PropertyDefs<InitializableBaseProperties>

  Inherited from InitializableBase._getSerializableProperties

### `Protected`_initializableChildCollections

- _initializableChildCollections(): IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

- Collections of child items to initialize. Items that fail to initialize are removed from the collection.

  #### Returns IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

  Inherited from InitializableBase._initializableChildCollections

### `Protected`_initializeChildren

- _initializeChildren(): Promise<void>

- Initializes child entities.

  #### Returns Promise<void>

  Inherited from InitializableBase._initializeChildren

### `Protected`_onDestroy

- _onDestroy(): Promise<void>

- Called to perform cleanup. Subclasses should override this method rather than destroy() to perform custom cleanup.

  #### Returns Promise<void>

  Inherited from InitializableBase._onDestroy

### `Protected`_onInitialize

- _onInitialize(): Promise<void>

- Called to perform initialization of the support/InitializableBase!InitializableBase. Subclasses should override this method rather than initialize() to perform custom initialization.

  #### Returns Promise<void>

  Overrides InitializableBase._onInitialize

### `Protected`_postInitialize

- _postInitialize(): Promise<void>

- Called after normal initialization. Note: Child items are initialized before this is called.

  #### Returns Promise<void>

  Inherited from InitializableBase._postInitialize

### `Protected`_toPropertyDef

- _toPropertyDef<T>(def): PropertyDef<T>

- Converts the value to a PropertyDef object.

  #### Type Parameters

  - T

  #### Parameters

  - def: PropertyDefSerializeMode | PropertyDefSerializeMode[] | PropertyDef<T>

    The value to convert.

  #### Returns PropertyDef<T>

  Inherited from InitializableBase._toPropertyDef

### assignProperties

- assignProperties(properties): void

- #### Parameters

  - properties: Partial<InitializableBaseProperties>

  #### Returns void

  #### Inherit Doc

  Inherited from InitializableBase.assignProperties

### assignPropertiesAsync

- assignPropertiesAsync(properties): Promise<void>

- #### Parameters

  - properties: Partial<InitializableBaseProperties>

  #### Returns Promise<void>

  #### Inherit Doc

  Inherited from InitializableBase.assignPropertiesAsync

### count

- count(sources, searchText, options?): AsyncIterable<CountResult, any, any>

- Counts the number of features that match a search phrase in the given feature sources.

  #### Parameters

  - sources: Iterable<FeatureSource, any, any> | Collection<FeatureSource>

    The feature sources to search.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<CountResult, any, any>

  An iterator of tasks/CountResult!CountResult containing count results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of data/FeatureSet!FeatureSet, though it may still succeed and return all count results.

- count(mapExtension, searchText, options?): AsyncIterable<CountResult, any, any>

- Counts the number of features that match a search phrase in the layers of the given mapping/MapExtension!MapExtension's associated map.

  #### Parameters

  - mapExtension: MapExtension

    The map extension whose map will be searched.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<CountResult, any, any>

  An iterator of tasks/CountResult!CountResult containing count results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of data/FeatureSet!FeatureSet, though it may still succeed and return all count results.

- count(map, searchText, options?): AsyncIterable<CountResult, any, any>

- Counts the number of features that match a search phrase in the layers of the given map.

  #### Parameters

  - map: Map

    The map to search.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<CountResult, any, any>

  An iterator of tasks/CountResult!CountResult containing count results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of data/FeatureSet!FeatureSet, though it may still succeed and return all count results.

### destroy

- destroy(): Promise<void>

- A clean-up function that should get called whenever the item is disposed of.

  #### Returns Promise<void>

  Inherited from InitializableBase.destroy

### finishAssignProperties

- finishAssignProperties(): Promise<void>

- #### Returns Promise<void>

  #### Inherit Doc

  Inherited from InitializableBase.finishAssignProperties

### getDefault

- getDefault<K>(key): InitializableBaseProperties[K]

- #### Type Parameters

  - K extends "failureMode"

  #### Parameters

  - key: K

  #### Returns InitializableBaseProperties[K]

  #### Inherit Doc

  Inherited from InitializableBase.getDefault

### getDefaults

- getDefaults(): InitializableBaseProperties

- #### Returns InitializableBaseProperties

  #### Inherit Doc

  Inherited from InitializableBase.getDefaults

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<InitializableBaseProperties>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

    Optional. If specified, only properties that support the given serialization mode will be returned.

  #### Returns PropertyDefs<InitializableBaseProperties>

  Inherited from InitializableBase.getSerializableProperties

### initialize

- initialize(): Promise<void>

- Initializes the item.

  #### Returns Promise<void>

  Inherited from InitializableBase.initialize

### isSupported

- isSupported(source): boolean

- Determines whether this service is able to search the given source, i.e. Whether there is at least one registered provider for that source.

  #### Parameters

  - source: FeatureSource

    The source to check.

  #### Returns boolean

### search

- search(sources, searchText, options?): AsyncIterable<Feature, any, any>

- Searches the given feature sources for features that match a search phrase.

  #### Parameters

  - sources: Iterable<FeatureSource, any, any> | Collection<FeatureSource>

    The feature sources to search.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<Feature, any, any>

  An iterator of data/FeatureSet!FeatureSet containing search results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of support/Cancellable!Cancellation, though it may still succeed and return all results.

- search(mapExtension, searchText, options?): AsyncIterable<Feature, any, any>

- Searches the layers of the given mapping/MapExtension!MapExtension's associated map for features that match a search phrase.

  #### Parameters

  - mapExtension: MapExtension

    The map extension whose map will be searched.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<Feature, any, any>

  An iterator of data/FeatureSet!FeatureSet containing search results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of data/FeatureSet!FeatureSet, though it may still succeed and return all results.

- search(map, searchText, options?): AsyncIterable<Feature, any, any>

- Searches the layers of the given map for features that match a search phrase.

  #### Parameters

  - map: Map

    The map to search.

  - searchText: string

    The text to search for.

  - `Optional` options: SearchOptions

    Options that affect the search.

  #### Returns AsyncIterable<Feature, any, any>

  An iterator of data/FeatureSet!FeatureSet containing search results. If the search is canceled, the returned iterator might end prematurely and reject with an instance of data/FeatureSet!FeatureSet, though it may still succeed and return all results.

### suggest

- suggest(sources, searchText, options?): Promise<SearchSuggestion[]>

- Provides search suggestions for the given feature sources.

  #### Parameters

  - sources: Iterable<FeatureSource, any, any> | Collection<FeatureSource>

    The feature sources to use.

  - searchText: string

    The text to provide suggestions for.

  - `Optional` options: SearchOptions

    Options that affect the suggest operation.

  #### Returns Promise<SearchSuggestion[]>

  An array of tasks/search/SearchSuggestion!SearchSuggestion containing suggest results. If the suggest is canceled, the returned promise may be rejected with an instance of data/FeatureSet!FeatureSet, but it may still succeed and return results.

- suggest(mapExtension, searchText, options?): Promise<SearchSuggestion[]>

- Provides search suggestions for the layers of the given mapping/MapExtension!MapExtension's associated map.

  #### Parameters

  - mapExtension: MapExtension

    The map extension that contains the map to use.

  - searchText: string

    The text to provide suggestions for.

  - `Optional` options: SearchOptions

    Options that affect the suggest operation.

  #### Returns Promise<SearchSuggestion[]>

  An array of tasks/search/SearchSuggestion!SearchSuggestion containing suggest results. If the suggest is canceled, the returned promise may be rejected with an instance of data/FeatureSet!FeatureSet, but it may still succeed and return results.

- suggest(map, searchText, options?): Promise<SearchSuggestion[]>

- Provides search suggestions for the layers of the given map.

  #### Parameters

  - map: Map

    The map to use.

  - searchText: string

    The text to provide suggestions for.

  - `Optional` options: SearchOptions

    Options that affect the suggest operation.

  #### Returns Promise<SearchSuggestion[]>

  An array of tasks/search/SearchSuggestion!SearchSuggestion containing suggest results. If the suggest is canceled, the returned promise may be rejected with an instance of data/FeatureSet!FeatureSet, but it may still succeed and return results.

### toJSON

- toJSON(serializeMode?): InitializableBaseProperties

- #### Parameters

  - serializeMode: SerializeMode = "all"

  #### Returns InitializableBaseProperties

  #### Inherit Doc

  Inherited from InitializableBase.toJSON