jcr-sql2 query starting with specific string

Avatar

Avatar
Validate 1
Level 3
cqvoyager
Level 3

Likes

14 likes

Total Posts

50 posts

Correct reply

5 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
cqvoyager
Level 3

Likes

14 likes

Total Posts

50 posts

Correct reply

5 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
cqvoyager
Level 3

17-01-2018

Hello Team,

In the jcr-sql2 query, is there any way to query the property having the value starts with certain string. 

I have overlapping tags, business:Finance, business:Insurance and global_search_business:Finance, global_search_business:Insurance. I want to only query the content tagged with all business: tags(but not global_search_business: tags).

SELECT * FROM [cq:PageContent] as node WHERE ISDESCENDANTNODE(node, '/content/geometrixx/en/news') AND CONTAINS([cq:tags], "business:") returning the content tagged with both.

I tried CONTAINS([cq:tags], "^business:"), its giving syntax error.

Even I tried LIKE, but no success.

Any suggestions please?

Best Regards,

Durga

Replies

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

277 likes

Total Posts

1,502 posts

Correct reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

17-01-2018

Can you share the query where you used like clause ?

Avatar

Avatar
Validate 25
Level 4
BigT168
Level 4

Likes

27 likes

Total Posts

155 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile

Avatar
Validate 25
Level 4
BigT168
Level 4

Likes

27 likes

Total Posts

155 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 5
Boost 3
View profile
BigT168
Level 4

17-01-2018

Can you add one more condition: and not CONTAINS([cq:tags], "global_search_business")

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

17-01-2018

Here is a good source of JCR SQL2 examples that may help you.

JCR Query Cheat Sheet - Community Wiki - Magnolia

Hope this helps...