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

Jonathan NORRIS jnorris at ist.ac.at
Mon Mar 12 16:24:03 CET 2018


Thank you for your help. Will adding this overwrite the original index 
data in store.yml?


On 03/12/2018 04:15 PM, Patrick Hochstenbach wrote:
> Please find in the attachment a correct configuration file
>
> BR
> Patrick
>
>
>
>> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20180312/6b3cbe97/attachment.html>


More information about the librecat-dev mailing list