[Girder-users] Find a file with a given name in a Collection

Zach Mullen zach.mullen at kitware.com
Thu Apr 13 14:29:04 EDT 2017


Hi Brian,

Items actually keep track of what top-level resource they live under in
their model data.  This isn't exposed via the core web API, so you'd want
to expose it via a plugin that would create a new endpoint.  You could do
this (mostly) in the database, by using find() with a query like the
following:

results = self.model('item').find({
    'name': {'$regex': searchRegex},
    'baseParentType': 'collection',
    'baseParentId': collectionId
})
return list(self.model('item').filterResultsByPermission(results,
self.getCurrentUser(), level=AccessType.READ, limit=limit, offset=offset))


It would probably also be a good idea to add the relevant indexes to the
item collection to make such searching much faster.


HTH,



Zach Mullen
Kitware, Inc.
919-869-8858

On Thu, Apr 13, 2017 at 1:45 PM, Brian E Chapman <Brian.Chapman at utah.edu>
wrote:

> Hi Everyone,
>
> I’m interested using the Python API to find all the items in a collection
> that match a name pattern. I’ve written a recursive function that goes
> through the items and folders (using the client listItem and listFolder
> methods) in the collection but it seems incredibly slow and I’m assuming
> there must be a better way of doing it. I’m using girder_client vs 2.0.0
>
>
> Brian E Chapman, Ph.D
> Associate Professor
> Department of Radiology and Imaging Sciences
> University of Utah
>
>
> _______________________________________________
> Girder-users mailing list
> Girder-users at public.kitware.com
> http://public.kitware.com/mailman/listinfo/girder-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/girder-users/attachments/20170413/60b52fc5/attachment.html>


More information about the Girder-users mailing list