Exact match option for gis.content.search

Idea created by mwawryk on Sep 24, 2018
    New
    Score130

    When trying to search and update content on AGOL there is only the option to search close matches and then somehow figure out if you have the correct one prior to updating the one from the list returned using gis.content.search.

    There should be an option to search for an exact match and not bother with a list that is returned. If for example,  I want to update Traffic_Closures the search will return Traffic_Closures_Historic. You have to know ahead of time which result will show up first so you can tell the search to give you the first result or the second result. In this case, I want to update both layers so I can't just get rid of similarly named features to make sure my first result is always the correct result.

     

    The use case is in https://www.esri.com/arcgis-blog/products/api-python/analytics/updating-your-hosted-feature-services-with-arcgis-pro-and… 

    It will often find a similarly named layer rather than the one you asked for.

     

    print("Search for original SD on portal…")
    sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]
    print("Found SD: {}, ID: {} n Uploading and overwriting…".format(sdItem.title, sdItem.id))
    sdItem.update(data=sd)
    print("Overwriting existing feature service…")
    fs = sdItem.publish(overwrite=True)

     

    You can improve the results by adding in title

    sdItem = gis.content.search("title:{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]

     

    but it still returns  Traffic_Closures_Historic as the first result when you search for Traffic_Closures

     

    Please add a search that will return an exact match without having to get a list back.