Find items with exact title using

08-14-2017 02:06 PM
Occasional Contributor III

Using the arcgis python API, is it possible to restrict search results to exact matches by title?

My query is title:City_Boundaries and owner:username and the search is returning other "City_Boundary" matches and would like to restrict to exact matches.

I reviewed this search documentation and could not find anything related to exact matches


7 Replies
New Contributor III

I had same issue. I  solved  the issue by adding  search field   as sort field and sorted on ascending order, then took the first one in the list. It worked for me. ,

#you can try something like: 

         item_to search ="your item to search"

         owner ="owner of the item"

  "title:"+ item_to search + " AND owner: " + owner, sort_field='title', sort_order='asc' )[0]


Occasional Contributor III

I agree you should be able to search for an exact match. I want to search by the name, for example, Golf_Course and get the ID so I can update it. Unfortunately, the first one it finds is a similarly named layer. Updating data requires an exact match, it seems strange that finding an exact match would not have been the default

Please vote on the following idea to have an exact match option. 

New Contributor II

Old but ran into this issue today.  You can add more logic after the to workaround the limitation:'title:{} AND owner:{}'.format(name,owner))

for search in searchData:
       if search["title"]==name:


New Contributor

If you would like to sort results by whether they contain some exact string, but the string does not necessarily have to make up the entire title, you can try something like this:

boston_data = = "title:Boston",
                                                      item_type='Feature Layer',

for item in boston_data:

   if "Boston" in str(item.title):




This will return only results that have the word "Boston" in them, but not limit your search results to titles that are exactly "Boston". 

New Contributor III

Portal and AGOL use Elasticsearch under the hood to store item metadata. It’s meant to do fast full text searches and returns ‘hits’. Don’t expect exact searches. 

Put more conditions to your query. Limit to your organization by passing an orgid or to a user. Drop max_items to 1 too. 

0 Kudos
by Anonymous User
Not applicable

Getting the same question, the workaround  I'm using is list comprehension. E.g :

searched_items=[item for item in gis."title: base_map", item_type="Map Service", max_items=20 if item.title=="base_map"]

Occasional Contributor

@ESRI how come this bug reported back to almost 5 years ago still not fixed. is it that hard or just not listening to your users. very disappointed