Search for empty fields

Questions, comments, discussions. Over time certain topics might be moved to their own category.
Post Reply
bebef
Posts: 10
Joined: Fri Aug 21, 2020 6:00 am

Search for empty fields

Post by bebef »

Hi everyone!

In the advanced search, is there a way to search for documents with particular fields empty (e.g. tags or cabinets)?
Basically, I want to search for documents that have not yet been tagged or put into a cabinet yet.

Cheers
User avatar
michael
Developer
Developer
Posts: 135
Joined: Sun Apr 19, 2020 6:21 am

Re: Search for empty fields

Post by michael »

Hello, this is no possible at the moment. Implementing this will require updating the search syntax to allow specifying blank or null. Since version 3.5 supports multiple search backends, ultimately this will depend on the search backend you choose to use.

For now you can write an index template to group all documents with those fields empty and that will achieve a similar result.
gtrot
Posts: 17
Joined: Tue Oct 01, 2019 9:03 pm

Re: Search for empty fields

Post by gtrot »

Hi,
I want to search for documents that have not yet been tagged or put into a cabinet yet.
In a index, you could use :

Code: Select all

{% if document.cabinets.count == 0 %} None
{% else %}
{% for cab in document.cabinets.all %}
{{ cab.label }}
{% endfor %}
{% endif %}
Source : viewtopic.php?f=15&t=219

G
Post Reply