Expand my Community achievements bar.

How to execute a conjunction of OR and AND in AEM GraphQL?

Avatar

Level 5

I want to have a filter like this:

const value = 
{
	AND: [
		{
			OR: [
				{ productVisibility_contains_none: ['authenticated', 'eap'] },
				{
					AND: [
						{ productVisibility_contains_all: ['authenticated'] },
						{ productVisibility_contains_none: ['eap'] },
					],
				},
			],
		},
		{ title_exists: true },
		{
			OR: [
				{ title_contains: $arg1 },
				{ author_contains: $arg1 },
				{ articleSource_contains: $arg1 },
				{ articleByline_contains: $arg1 },
				{ articleSubtitle_contains: $arg1 },
				{ primaryCategoryTag_contains_some: [$arg1, $arg1_cap, $arg1_low] },
				{ categoryTags_contains_some: [$arg1, $arg1_cap, $arg1_low] },
			],
		},
		{ primaryCategoryTag_contains: $categoryTitles },
	],
};

as you can see there's conjunction of OR and AND operations, however in AEM GQL you only get either OR or AND for all the high level filters. I wanted to know if it would be possible to perform the above in AEM or not?

2 Replies

Avatar

Employee

@spidey1405 

Please see the link below, the highlighted line says, that in AEM, for a GQL filter AND is implicit while OR needs to be mentioned explicitly. Can you try your query with this format:
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-ap...

 

Avatar

Level 5

Hello @krati_garg 

 

Thanks for the quick response, however if you see my question and compare the same with the documentation you would observe that this solution won't work for me as I need to perform a high level OR as well as AND filtering among multiple fields.

page footer