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

Jonathan NORRIS jnorris at ist.ac.at
Fri May 29 12:04:15 CEST 2020


Using the native search did the trick. With the following query I could 
filter out all users that did not have the field:

     my $hits = searcher->native_search('user', {
         limit => 1000,
         query => {
             'exists' => {
                 'field' => 'favorite_publications'
             }
         }
     });


Thanks for your help!
Jonathan
IST Austria

On 5/28/20 15:39, Patrick Hochstenbach wrote:
> You can do a native ElasticSearch query in Catmandu. The `exists` query would be something that you may need https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html
>
>
> Something like:
>
> my $hits = searcher->search('user', {
>      query => {
>          'exists' => {
>              'field' => 'favorite_publications'
>          }
>      } );
>
> Patrick
>
>> On 28 May 2020, at 15:27, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>>
>> Apologies as I forgot to mention that I was doing this in one of the search route files and was only using the command line as an example for the CQL.
>>
>> In reality I am using a line of code like this:
>>
>>      my $hits = searcher->search('user', {cql => ["favorite_publications<>0"]});
>>
>> I am using it for an export of the users favorite publications and have a fix file which leaves only the username and favorite publication field which works nicely, now I'm just trying to figure out how to query specifically for the users who have this field. Because of the max limit of 1000 I cannot return all users and filter in the fix file.
>>
>> Thanks,
>> Jonathan
>> IST Austria
>>
>> On 5/28/20 15:08, Patrick Hochstenbach wrote:
>>> I don’t know by heart how to do this in an elastic search query but with a Catmandu fix this is pretty easy:
>>>
>>> $ bin/librecat export main --bag user to TSV --fix 'select exists(favorite_publication)'
>>>
>>>> On 28 May 2020, at 14:58, Jonathan NORRIS <jnorris at ist.ac.at> wrote:
>>>>
>>>> favorite_publication



More information about the librecat-dev mailing list