[librecat-dev] cql query to get users by department

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Mon Mar 12 16:15:52 CET 2018


Please find in the attachment a correct configuration file

BR
Patrick

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.yml
Type: application/octet-stream
Size: 343 bytes
Desc: not available
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20180312/b0a6df31/attachment.obj>
-------------- next part --------------

> On 12 Mar 2018, at 16:06, Patrick Hochstenbach <Patrick.Hochstenbach at UGent.be> wrote:
> 
> Hello
> 
> The ?department? index is not defined in the default configuration files for user queries.
> 
> You need to add it in your layer in  a new configuration file (e.g. myindexes.yml) with content:
> 
> store:
> search:
>   options:
>     bags:
>       user:
>         cql_mapping:
>           indexes:
>             department:
>                op:
>                  'all': true
>                  'any': true
>                  '=': true
>                  'exact': {field: 'department.name.exact'}
>                field: ['department._id', 'department.name?]
> 
> Then reindex your data ?./index.sh? index.
> 
> Now you can find all the users with a affiliation:
> 
> $ bin/librecat user list 'department = 9999?
> 
> Or as you wrote in your Perl code
> 
> Best regards
> Patrick
> 
>> On 12 Mar 2018, at 12:30, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>> 
>> Hello,
>> 
>> I haven't been able to find an example of this in the source code. Basically I just want to query for all users of a particular department. My attempt here is not working:
>> 
>> get '/groups/:group' => sub {
>> 
>>    my $group_name = params->{group};
>> 
>>    my %search_params = (cql => ["department=$group_name"]);
>> 
>>    my $users = LibreCat->searcher->search('user', \%search_params);
>> 
>>    template 'groups/group', {
>>      group_name => $group_name,
>>      users => $users
>>    };
>> };
>> 
>> My user looks like this:
>> 
>> _id: A0E86400-1266-11E8-9236-8266539212D2
>> account_status: active
>> date_created: 2018-02-15T15:41:03Z
>> date_updated: 2018-03-12T09:20:08Z
>> department:
>> - _id: NiBa
>> email: james.wallace at ist.ac.at
>> first_name: James
>> full_name: James Wallace
>> last_name: Wallace
>> But when I run the query with 'NiBa' as the group name then I get no results. Is my syntax or cql query correct?
>> 
>> Thanks,
>> 
>> Jonathan Norris
>> 
>> IST Austria
>> _______________________________________________
>> librecat-dev mailing list
>> - send list mails to librecat-dev at lists.uni-bielefeld.de
>> - to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
>> - project website: http://librecat.org/
> 
> _______________________________________________
> librecat-dev mailing list
> - send list mails to librecat-dev at lists.uni-bielefeld.de
> - to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
> - project website: http://librecat.org/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20180312/b0a6df31/attachment.asc>


More information about the librecat-dev mailing list