Map service Find method

Searches the attributes of one or more layers in a data frame, in a map service for a given search string.

Find (MapDescription MapDescription, ImageDisplay MapImageDisplay, string SearchString, bool Contains, string SearchFields, esriFindOption FindOption, int[] LayerIDs)




Used to define the map extent and visibility of layers.


Used to determine whether layers are visible or not based on the current map scale.


The string value searched for during the find process.


Whether the attribute value contains the search string (true) or is an exact match (false). If true, the search is not case sensitive. If false, the search is case sensitive.


A comma delimited list of field names used during the search. If empty or null, all fields are searched.


An enumeration is used to define whether all layers or only visible layers are searched.


An array of layers ids for layers to search. If empty or null, all layers can be searched.

Return Value

An array of MapServerFindResult objects, one for each record that contains a match. If multiple fields in the same record match the search string, only one MapServerFindResult referencing the first matched field is returned.


There are two key differences between the Find and the Map Service methods QueryFeatureCount, QueryFeatureCount2, QueryFeatureIDs, QueryFeatureIDs2, QueryFeatureData, and QueryFeatureData2:

  1. Find can work with multiple layers while the query methods work with a single layer.
  2. Find only requires a search string, whereas the query methods use a QueryFilter. This allows query methods to utilize either an attribute filter (SQL expression) or a spatial filter.

Layer visibility depends on whether the layer is on or off (the Visible property on a layers LayerDescription) or whether the layer is on, but not visible due to scale dependencies. Each layer maintains a LayerDescription available via the MapDescription. LayerDescriptions array. Scale dependency for a layer is available via the MinScale and MaxScale properties on MapLayerInfo, available via the MapServerInfo. MapLayerInfos array. The ImageDisplay parameter is used to determine layer visibility based on scale dependencies.

The amount of information (e.g. number of MapServerFindResult objects) returned from a call to the Find method may be restricted by the map service. The default maximum value for the number of results returned from a call to the Find method is 500. If 600 records are matched, only the first 500 results will be returned. The maximum number of results cannot be changed via the ArcGIS Server SOAP API. The map service itself must be configured to return more results, if necessary. If the maximum result limit has been reached, a technique to iterate through blocks of results is presented in the QueryFeatureIDs method remarks.



MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer";


MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());

MapDescription mapdesc = mapinfo.DefaultMapDescription;


ImageDisplay imgdisp = new ImageDisplay();

imgdisp.ImageHeight = 500; //pixels

imgdisp.ImageWidth = 500; //pixels

imgdisp.ImageDPI = 96;


string searchstring = "Washington";


bool contains_searchstring = true;


string fieldname = string.Empty; // all fields


esriFindOption findoption = esriFindOption.esriFindAllLayers;


LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;

int[] layerids = new int[layerdescriptions.Length];

int i = 0;


foreach (LayerDescription layerdesc in layerdescriptions)


      style="font-size: 12pt;">layerids.SetValue(layerdesc.LayerID, i++);



MapServerFindResult[] findresults = mapservice.Find(mapdesc, imgdisp, searchstring, contains_searchstring, fieldname, findoption, layerids);


Dim mapservice As MapService_MapServer = New MapService_MapServer(

mapservice.Url = "http://localhost:6080/arcgis/services/MapService/MapServer"


Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription


Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96


Dim searchstring As String = "Washington"

Dim contains_searchstring As Boolean = True

Dim fieldname As String = String.Empty ' all fields

Dim findoption As esriFindOption = esriFindOption.esriFindAllLayers

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription


For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1



Dim findresults As MapServerFindResult() = mapservice.Find(mapdesc, imgdisp, searchstring, contains_searchstring, fieldname, findoption, layerids)


String serviceURL = "http://localhost:6080/arcgis/services/MapService/MapServer";

MapServerBindingStub mapService = new MapServerBindingStub(serviceURL);

String mapName = mapService.getDefaultMapName();

MapServerInfo mapInfo = mapService.getServerInfo(mapName);

MapDescription mapDesc = mapInfo.getDefaultMapDescription();


ImageDisplay imgDisp = new ImageDisplay();

imgDisp.setImageHeight(500); //Height of the image in pixels

imgDisp.setImageWidth(500); //Width of the image in pixels



String searchString = "Washington";

boolean containsSearchString = true;


String fieldName = ""; // all fields


EsriFindOption findOption = EsriFindOption.esriFindAllLayers;


LayerDescription[] layerDescriptions = mapDesc.getLayerDescriptions();
int[] layerIDs = new int[layerDescriptions.length];

for (int i=0; i< layerDescriptions.length; i++){

  layerIDs[i] = layerDescriptions[i].getLayerID();



MapServerFindResult[] findResults = mapService.find(mapDesc, imgDisp, searchString, containsSearchString, fieldName, findOption, layerIDs);

System.out.println("Result Count: " + findresults.length);