[Girder-users] Querying by metadata

Jonathan Beezley jonathan.beezley at kitware.com
Thu Jun 29 12:40:53 EDT 2017


For clarification, do you mean collections in the sense of mongodb
collections, or girder collections?  It shouldn't be any problem, for
example, searching all items regardless of the parent collection they
belong in.

On Thu, Jun 29, 2017 at 11:27 AM, Zach Mullen <zach.mullen at kitware.com>
wrote:

> One of the main limitations (or perhaps features?) of mongodb is that a
> query is applied to only one collection at a time, so your search function
> would make one query per collection that you wish to search. So, in the
> case you describe, you'd need to loop over some dynamic set of collections
> and query each one. Or, create some secondary collection that aggregates
> all of the data with this metadata field, and contains references to other
> collections in its documents.
>
> Thanks,
>
> -Zach
>
> On Thu, Jun 29, 2017 at 11:22 AM, Andrés Fortier <andres at ekumenlabs.com>
> wrote:
>
>> Hi Zach,
>> thanks for the quick reply. What you say makes as lot of sense, my next
>> question on this was going to be about performance and indexes for this
>> kind of search :).
>>
>> Just to clarify, if we go this road, is there a way to query all
>> collections at once or we need to run the query for each collection? I'm
>> asking because we may need to create collections on the fly as the system
>> runs, so it would be great to be able to query all elements regardless of
>> the collection they belong to.
>>
>> Thanks again,
>> Andy
>>
>> On Thu, Jun 29, 2017 at 11:48 AM, Zach Mullen <zach.mullen at kitware.com>
>> wrote:
>>
>>> Hi Andy,
>>>
>>> Thanks for reaching out! This is actually a common sort of use case, but
>>> Girder out-of-the-box does not support it (yet). The main reason for that
>>> is because these sorts of queries should typically be performed against a
>>> database index so that they can scale up to large numbers of folders/items.
>>> So, the recommended route for this case is to create a small plugin that
>>> makes sure your desired search field is indexed. To achieve that, you'd add
>>> a line like:
>>>
>>>     ModelImporter.model('item').ensureIndex(['meta.type', {'sparse':
>>> True}])
>>>
>>> Then, you'd want to probably add a small API endpoint to search by this
>>> field, and perhaps even some UI augmentation to expose it somewhere. Let me
>>> know if you need help with those other steps.
>>>
>>> Thanks,
>>>
>>> Zach Mullen
>>> Kitware, Inc.
>>> 919-869-8858 <(919)%20869-8858>
>>>
>>>
>>> On Thu, Jun 29, 2017 at 9:18 AM, Andrés Fortier <andres at ekumenlabs.com>
>>> wrote:
>>> >
>>> > Hi all,
>>> > first of all, sorry of this is a trivial question, just getting
>>> started with Girder. We are currently evaluating using Girder as a backend
>>> to store resources (either a folder or a file). One of the requirements we
>>> have is that a resource may have 0, 1 or more "types" (although it will
>>> most likely be 1 for a starter), which can be plain strings. Also, we want
>>> to be able to search resources by type, even if they are in different
>>> collections.
>>> >
>>> > Initially we thought on attaching a type property to a resource
>>> metadata, which could be an array of strings. However the search bar in the
>>> web front-end doesn't seem to support search by metadata, so I was
>>> wondering: is metadata search supported on a collection? if yes, how about
>>> cross-collection search? If no, should I write a plugin to do that?
>>> >
>>> > Any hints / pointers are much appreciated.
>>> >
>>> > Thanks!
>>> > Andy
>>> >
>>> > _______________________________________________
>>> > Girder-users mailing list
>>> > Girder-users at public.kitware.com
>>> > http://public.kitware.com/mailman/listinfo/girder-users
>>> >
>>>
>>
>>
>
> _______________________________________________
> 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/20170629/56c335b8/attachment.html>


More information about the Girder-users mailing list