[librecat-dev] how to have field remain in user after account save

Jonathan NORRIS jnorris at ist.ac.at
Thu May 28 14:58:22 CEST 2020


Ah I see. Is there a way I can query for every user that has a 
favorite_publication field present with any values in it? Basically 
filtering out any user without a favorite_publication field.

Thanks,
Jonathan
IST Austria

On 5/28/20 14:23, Patrick Hochstenbach wrote:
> This could be the correct behavior. I have in my own installation defined `z_archive_id` that uses the same tricks as you have:
>
> $ bin/librecat publication list
> ...
> count: 456
> $ bin/librecat publication list 'z_catalog_id="rug01:001536660”'
>> count: 1
> $ bin/librecat publication list ‘z_catalog_id<>"rug01:001536660”’
>> count: 455
>
> The last indeed returns the whole database except the record that doesn’t have `rug01:001536660`.
>
> A second issue is that your `favorite_publications` is an array. When you search for "favorite_publications<>0” and one of the values
> in your array is not `0` or the array is empty ..then you get a match. So indeed the ElasticSearch could return exactly what you asked for: everything.
>
>
>> On 28 May 2020, at 14:13, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>>
>> Funnily enough it works both ways, if I keep the "cql=" part it works the same as without it. Either way, the query doesn't work.
>>
>> I have added some extra operators to the store yaml:
>>
>> favorite_publications:
>>    op:
>>      'all': true
>>      'any': true
>>      '=': true
>>      '<>': true
>>    field: "favorite_publications"
>>
>> And now I can get data returned with this query: bin/librecat user list "favorite_publications=3853"
>>
>> But it still returns all users for: bin/librecat user list "favorite_publications<>0"
>>
>> Thanks,
>> Jonathan
>> IST Austria
>>
>> On 5/28/20 13:08, Patrick Hochstenbach wrote:
>>> Hey
>>>
>>> The `cql=` is not correct. All the queries on the command line `list` are CQL queries by default. In theory this should be the query:
>>>
>>> bin/librecat user list ‘favorite_publications <> 0’
>>>
>>> Patrick
>>>
>>>> On 28 May 2020, at 12:54, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>>>>
>>>> Hey,
>>>>
>>>> Thanks, I copied the existing read_only_fields hook and made a new one for my user fields. It worked like a charm!
>>>>
>>>> I have another thing I am trying to figure out. I need a cql query to return me only users who have a value for my new field. I am storing a list of publication ids in the user object and the field is called 'favorite_publications'.
>>>>
>>>> It looks like this in the user object yaml:
>>>>
>>>> favorite_publications:
>>>> - 3853
>>>> - 3950
>>>> - 4118
>>>>
>>>>
>>>> Here is the field in store.yml:
>>>>
>>>> user:
>>>>    mapping:
>>>>      properties:
>>>>        favorite_publications: {type: text, analyzer: tag}
>>>>    cql_mapping:
>>>>      indexes:
>>>>        favorite_publications:
>>>>          op:
>>>>            '<>': true
>>>>          field: "favorite_publications"
>>>>
>>>>
>>>> I imagine the cql to be like: bin/librecat user list 'cql=favorite_publications<>0'
>>>>
>>>> However this query returns me the full list of users rather than the one user which actually has a favorite_publications field.
>>>>
>>>> Can you advise on how I could achieve what I am trying to do?
>>>>
>>>>
>>>> Thanks for your help!
>>>> Jonathan
>>>> IST Austria
>>>>
>>>> On 5/27/20 15:02, Patrick Hochstenbach wrote:
>>>>> Hi,
>>>>>
>>>>> One way is using the LibreCat::Hook::read_only_fields
>>>>>
>>>>> Somewhere in your config/catmandu.local.yml define:
>>>>>
>>>>> hook:
>>>>>        my_read_only_fields:
>>>>>          - legacy_id
>>>>>
>>>>> And in your config/hooks.yml
>>>>>
>>>>> publication-update:
>>>>>        before_fixes:
>>>>>            - my_read_only_fields
>>>>>
>>>>> In this way the legacy_id fileds are kept in the original state when updating a record via the forms.
>>>>>
>>>>> Patrick
>>>>>
>>>>>
>>>>>> On 27 May 2020, at 10:34, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> Is there a way to configure a field in store.yml to have it remain in an index document after saving the document via a form when there is no entry for that field in the form?
>>>>>>
>>>>>> As in, say I have a new field in the user mapping in store.yml which is populated via some process somewhere in Librecat, but I don't have a form field for this in the user account form. Can I configure the field in store.yml so that it is not removed after I save the user via the user's account form?
>>>>>>
>>>>>> Thanks,
>>>>>> Jonathan
>>>>>> 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/



More information about the librecat-dev mailing list