Is it possible to filter_query attributes outside the 'content'-object?

Hi all!

Is that possible to filter by attribute from outside the “content”-object?

Documentation says that

Every field in the content field can be used as the ATTRIBUTE key in your filter_query .

But what about the fields outside the “content”-object? Such as “lang”, “slug”, “id”, “tag_list”?
For example, I want to create a query where “tag_list”-array has on of the given values OR “category”-field equals to certain value. (“category”-field is my custom field within “content”).

I haven`t found a solution for that yet.

Any help apprecated.

Hello @YMarynych,

with the filter_query parameter you can search only in the content object. When you need to filter for the published_at field you can use for example the published_at_gt or published_at_lt or in the case of the first_published_at field with first_published_at_gt or first_published_at_lt parameter.
It is possible to use the by_slugsparameter and wildcards, Here are examples from the documentation: by_slugs=authors/john,authors/max, by_slugs=authors/*,articles/*

The language selection is being done by defining (field-level translation - Internationalization - Storyblok) the local as the value for the language parameter.

Filtering for tags from the tag list is possible with the with_tag parameter but using the filter_query parameter is much more flexible because you can use a multi-option field and provide a datasource as the source with the selectable tags which can then be filtered for (Storyblok API Documentation)

Best regards

Thanks for help @Hannes !

Yes, I agree - “filter_query” is way more flexible than “with_tag”-parameter, especially in my case. But its still not clear for me, is that possible to filter by tags in some way within “filter_query” instead of using “with_tag”-parameter?

Hello @YMarynych,

with the filter_query you can filter only inside of the content type. The "tag_list" isn’t part of the content type so you won’t be able to use filter_query on those tags.

Best regards

1 Like