contentful.rb
contentful.rb copied to clipboard
Querying for related entries by their contentType
Hello! I'm having an issue trying to query for entries by a related entry's contentType.
I have 3 models - Resource, BlogPost and Video
I'm trying to query this model:
Resource
which has the single-reference field:
RESOURCE:
entry=>BlogPostorVideo
My query using the gem looks like this:
Content::Resource.all('fields.entry.sys.contentType.sys.id': 'blogPost', include: 4)
(the internal implementation of this should be fine, as include: 4 is passed correctly as an option along with the field query in the logs)
I get no errors.
What I get back is:
100 Resource entries, containing a mix of BlogPost and Video entries linked to the entry field
What i want is:
Only Resource entries with BlogPosts linked to the entry field
Any clue where the issue is? Thank you!
Hi @0xStarcat!
Currently this is not possible with our Search API, you will have to filter manually by type, as our Search API only allows to use the relationship queries to filter by a value on the relationship and not by the relationship type itself.
Cheers