Search on Contentful for null/not null fields

Hi there,

On Contentful website, I would like to filter by a field that is/is not null.
Is that possible?

8 Likes

Hi @kennedy,

This is not a possibility directly through our Web Interface, but you could do that using our Delivery or Management APIs with the existence parameter:

https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters/existence

That’s something I’ve needed on a number of occasions too and have previously enquired about. @gabriel is it it a query you get a lot and is there any prospect of it making it onto the UI roadmap?

5 Likes

Any chance this will be implemented in the future? I’ve had a lot of use cases for this… :confused:

BTW, for anyone getting here via a desperate google search, here’s my workaround:

  • Open the content panel in the contentful web view
  • Filter for the content type in question (e.g. clients)
  • Open Dev Tools
  • Go to network tab
  • Look for the corresponding entries request (should have content_type={client} as URL param)
  • Right click -> Open the request in a new tab
  • Add &{field you want to filter}[exists]=true to the URL params

In the end, your URL should look something like this:
https://api.contentful.com/[...]/entries?content_type=client&access_token={access token}&fields.company[exists]=true (where client and company are examplary values)

BTW you can get an access token for this kind of request from the authorization request header of the entries request (omit the Bearer keyword)

6 Likes

Hi @lukas.mueller, @scott.hogan. Since it seems this feature is interesting, I will forward this request to our Product team and keep you updated in this post.

10 Likes

Any updates on if this has been implemented in the web UI?

3 Likes

it should not be too difficult for your engineering team to add an “is empty” option to the data-search-filter-role=“operator” list - the lack of this makes it very cumbersome to work with large amounts of data.

Any news on this? Our Editors would love to be able to do this as the need to find entries where certain fields do/don’t have content has come up several times.

2 Likes

This is sorely lacking, please prioritize this feature