How can this be done? I want to be able to search all contents (layers, collection, service, maps, apps .,ect) found in my Portal.
<SPAN class="comment token">#import modules</SPAN> <SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> <SPAN class="operator token">*</SPAN> <SPAN class="keyword token">from</SPAN> IPython<SPAN class="punctuation token">.</SPAN>display <SPAN class="keyword token">import</SPAN> display <SPAN class="comment token">#declare a connection to your portal</SPAN> gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"portal URL"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"user"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"pass"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Successfully logged in as: "</SPAN> <SPAN class="operator token">+</SPAN> gis<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>user<SPAN class="punctuation token">.</SPAN>username<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#search for items without passing in string values to the query or type parameters</SPAN> items <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">''</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">''</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> items<SPAN class="punctuation token">:</SPAN> display<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Perfect! Thank You!!
Seth's answer is correct, but the gis.content.search() method only returns the first 10 items found. You need to add the parameter "max_items=" and set the value greater than the number of items you have in your Portal.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.