aem query builder apply two opertion at single time | Community
Skip to main content
Level 2
June 4, 2024
Solved

aem query builder apply two opertion at single time

  • June 4, 2024
  • 3 replies
  • 811 views

Hi All,

I have a requirement in that I have to search for a page having the jcr property "topicCategory" or "articleTopicCategories"

and the property value should be  "financial_adjustments_and_payments" or it can start with "Financial_Adjustments_and_Payments".

and property value can be the upper case or lower case.

 

articleTopicCategories
String
Postage_By_Phone,Financial_Adjustments_and_Payments,Managing_Postage_Funds,Invoice_and_Statement_Management
topicCategory
String
financial_adjustments_and_payments
topicCategory
String[]
cellular_hotspot_device, financial_adjustments_and_payments, changing_account_information

so I have written this query.

 

path=/content/pb/us
type=cq:Page
group.1_property=jcr:content/topicCategory
group.1_property.value=%Financial_Adjustments_and_Payments%

group.1_property.operation=equalsIgnoreCase

group.1_property.operation=like
group.2_property=jcr:content/articleTopicCategories
group.2_property.value=%Financial_Adjustments_and_Payments%

group.2_property.operation=like
group.2_property.operation=equalsIgnoreCase
group.p.or=true
p.limit=-1

 

so If you read the above query, I have applied like and equal ignore case property. but at one time only one operation is working. Either like or either equal ignore case. 

Is there any way to fix this query .

@aanchal-sikka

arunpatidar

EstebanBustamante

@hrishikeshkagne 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by HrishikeshKagne

Hi @raushan ,

In AEM Query Builder, you can't directly apply multiple operations (like equalsIgnoreCase and like) on a single property at the same time within the same group. To achieve the desired result, you need to use multiple conditions to cover all the cases.

Here's how you can construct the query to handle your requirement:

  1. Search for topicCategory or articleTopicCategories.
  2. The value should be financial_adjustments_and_payments or start with Financial_Adjustments_and_Payments.
  3. The value can be in upper case or lower case.

You can structure the query to check all combinations using multiple conditions grouped logically. Here's how you can do it:

 

path=/content/pb/us type=cq:Page group.p.or=true 1_group.p.or=true 1_group.1_property=jcr:content/topicCategory 1_group.1_property.value=financial_adjustments_and_payments 1_group.1_property.operation=equalsIgnoreCase 1_group.2_property=jcr:content/topicCategory 1_group.2_property.value=Financial_Adjustments_and_Payments% 1_group.2_property.operation=like 2_group.p.or=true 2_group.1_property=jcr:content/articleTopicCategories 2_group.1_property.value=financial_adjustments_and_payments 2_group.1_property.operation=equalsIgnoreCase 2_group.2_property=jcr:content/articleTopicCategories 2_group.2_property.value=Financial_Adjustments_and_Payments% 2_group.2_property.operation=like p.limit=-1

 

Explanation

  1. Path and Type:

    • path=/content/pb/us
    • type=cq:Page
  2. First Group (1_group.p.or=true):

    • 1_group.1_property: Checks jcr:content/topicCategory for financial_adjustments_and_payments (case insensitive).
    • 1_group.2_property: Checks jcr:content/topicCategory for values starting with Financial_Adjustments_and_Payments (case insensitive).
  3. Second Group (2_group.p.or=true):

    • 2_group.1_property: Checks jcr:content/articleTopicCategories for financial_adjustments_and_payments (case insensitive).
    • 2_group.2_property: Checks jcr:content/articleTopicCategories for values starting with Financial_Adjustments_and_Payments (case insensitive).
  4. Combine Groups with OR (group.p.or=true):

    • The outer group.p.or=true ensures that pages matching either the first group or the second group are included in the results.
  5. Limit:

    • p.limit=-1 to get all matching results without limit.

This query ensures that it covers both properties (topicCategory and articleTopicCategories) and handles both case sensitivity and partial matches.

3 replies

HrishikeshKagne
Community Advisor
HrishikeshKagneCommunity AdvisorAccepted solution
Community Advisor
June 4, 2024

Hi @raushan ,

In AEM Query Builder, you can't directly apply multiple operations (like equalsIgnoreCase and like) on a single property at the same time within the same group. To achieve the desired result, you need to use multiple conditions to cover all the cases.

Here's how you can construct the query to handle your requirement:

  1. Search for topicCategory or articleTopicCategories.
  2. The value should be financial_adjustments_and_payments or start with Financial_Adjustments_and_Payments.
  3. The value can be in upper case or lower case.

You can structure the query to check all combinations using multiple conditions grouped logically. Here's how you can do it:

 

path=/content/pb/us type=cq:Page group.p.or=true 1_group.p.or=true 1_group.1_property=jcr:content/topicCategory 1_group.1_property.value=financial_adjustments_and_payments 1_group.1_property.operation=equalsIgnoreCase 1_group.2_property=jcr:content/topicCategory 1_group.2_property.value=Financial_Adjustments_and_Payments% 1_group.2_property.operation=like 2_group.p.or=true 2_group.1_property=jcr:content/articleTopicCategories 2_group.1_property.value=financial_adjustments_and_payments 2_group.1_property.operation=equalsIgnoreCase 2_group.2_property=jcr:content/articleTopicCategories 2_group.2_property.value=Financial_Adjustments_and_Payments% 2_group.2_property.operation=like p.limit=-1

 

Explanation

  1. Path and Type:

    • path=/content/pb/us
    • type=cq:Page
  2. First Group (1_group.p.or=true):

    • 1_group.1_property: Checks jcr:content/topicCategory for financial_adjustments_and_payments (case insensitive).
    • 1_group.2_property: Checks jcr:content/topicCategory for values starting with Financial_Adjustments_and_Payments (case insensitive).
  3. Second Group (2_group.p.or=true):

    • 2_group.1_property: Checks jcr:content/articleTopicCategories for financial_adjustments_and_payments (case insensitive).
    • 2_group.2_property: Checks jcr:content/articleTopicCategories for values starting with Financial_Adjustments_and_Payments (case insensitive).
  4. Combine Groups with OR (group.p.or=true):

    • The outer group.p.or=true ensures that pages matching either the first group or the second group are included in the results.
  5. Limit:

    • p.limit=-1 to get all matching results without limit.

This query ensures that it covers both properties (topicCategory and articleTopicCategories) and handles both case sensitivity and partial matches.

Hrishikesh Kagane
h_kataria
Community Advisor
Community Advisor
June 6, 2024

Well, I think you can achieve it using Xpath as well.
Something like 

/jcr:root/content/pb/us//* [ (jcr:like(fn:lower-case(@topicCategory), '%Financial_Adjustments_and_Payments%')) ]
kautuk_sahni
Community Manager
Community Manager
June 13, 2024

@raushan Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni