Search DAM assets and Cq pages using lastModified date | QueryBuilder - aem

I am querying the cq pages and assets based on the last modified date.
Here is the the text that has to be put in query builder debugger:
fulltext=geometrix
1_group.p.or=true
1_group.1_group.p.and=true
1_group.1_group.path=/content
1_group.1_group.type=cq:Page
1_group.1_group.relativedaterange.property=jcr:content/cq:lastModified
1_group.1_group.relativedaterange.lowerBound=-1M
1_group.2_group.p.and=true
1_group.2_group.path=/content/dam
1_group.2_group.type=dam:Asset
1_group.2_group.relativedaterange.property=jcr:content/cq:lastModified
1_group.2_group.relativedaterange.lowerBound=-1M
It doesn't work.
Here I have to apply lowerbound on both cq:pages and dam assets.
Where am I going wrong?

Your query is full right except the thing that dam:asset don't have cq:lastModified property but it has jcr:lastModified.
So instead of using:
1_group.2_group.relativedaterange.property=jcr:content/cq:lastModified
you can use:
1_group.2_group.relativedaterange.property=jcr:content/jcr:lastModified
and it will start working.

Related

Fulltext query on properties and subnodes does not work properly - AEM Query Builder

I'm trying to perform a query on the CRX of a 6.2 Adobe AEM version.
I have to execute a fulltext query on (aNode is a generic subnode of /content/connect/it/supplier/):
1) all properties of /content/connect/it/supplier/aNode/jcr:content
2) all subnodes of /content/connect/it/supplier/aNode/jcr:content/service/legal
as you can see, highlighted in red, in the following picture of the JCR OAK:
To achive my target I've used the following query using AEM query builder debugger:
path:/content/connect/it/supplier
orderBy:#jcr:score
p.limit:-1
group.p.or:true
group.1_fulltext:*something to search*
group.1_fulltext.relPath:jcr:content
group.2_fulltext:*something to search*
group.2_fulltext.relPath:jcr:content/service/legal
Searching for 'something to search' on the properties of jcr:content works properly.
I'm not able to search on the subnodes of 'jcr:content/service/legal'. It does not retrieve anything.
Try:
path:/content/connect/it/supplier
orderBy:#jcr:score
p.limit:-1
fulltext=*something to search*
group.p.or:true
group.1_relPath:jcr:content
group.2_relPath:jcr:content/service/legal
That should work. See the following links:
https://helpx.adobe.com/experience-manager/6-2/sites/developing/using/querybuilder-api.html
http://www.aemcq5tutorials.com/tutorials/adobe-aem-cq5-tutorials/aem-query-builder/
relPath is always limiting the search to the element specified. With that approach you will not reach your goal. You could remove the relPath for group.2 which might give you too many results.
fulltext=something to search
group.p.or=true
group.1_path=/content/connect/it/supplier
This automatically searches the fulltext in jcr:content and the subnode below it. This will server your purpose of searching in jcr:content properties and subnodes of jcr:content
If you want to search the fulltext of multiple paths
fulltext=something to search
group.p.or=true
group.1_path=/content/connect/it/supplier
group.2_path=/content/connect/it/xyz

How to include Tag names in AEM search query builder while Tag IDs are saved in the repository

In AEM, how can we write a query as the default search works, where a Tag ID is saved for an asset, while the user wanted to search by the Tag Name/jcr:title?
For example, we can search for assets that has a particular Tag assigned. As below:
the way there are assigned is as follows:
And are saved in the repository as ID's.. as below:
For example, a tag hierarchy:
TAG ID:
/etc/tags/SXM/shows/entertainment/kids/8216/1073743514
The TAG NAME for the above:
SXM > Shows > Talk > Kids > Kids Place Live > Weird Al April
I tried the below but does not work?
type=dam:Assets
path=/content/dam/
tagsearch=SXM:Shows/Talk/Kids/Kids Place Live/Weird Al April
I was able to resolve this and posting the answer.
There is a predicate tagsearch that would build the tag hierarchy to the search query.
The below worked for me:
type=dam:Assets
path=/content/dam/
tagsearch=Weird Al April
or
type=dam:Assets
path=/content/dam/
tagsearch=Kids Place Live
or
type=dam:Assets
path=/content/dam/
tagsearch=Kids

How to perform full text search under a given path and under pages that are Activated only in AEM 6 using Query builder?

I want to perform a full text search but under a specific path and under pages that are Activated or Published only.
So if we find the text under /content/skynet/contact-us/jcr:content/content/slider/items and the page contact-us.html is not activated then this hit should be ignored
path=/content/skynet
type=cq:Page
group.p.or=true
group.1_fulltext=icon-phone
group.1_fulltext.relPath=jcr:content
property=cq:lastReplicationAction
property.value=Activate
p.limit=1
p.offset=0
Your property cq:lastReplicationAction would be on the cq:PageContent node and not on cq:Page. So giving a relative path to the property should fix your issue.
path=/content/skynet
type=cq:Page
fulltext=icon-phone
fulltext.relPath=jcr:content
property=jcr:content/cq:lastReplicationAction
property.value=Activate
p.limit=-1 //To display all the results

Search for pages tagged with a tag title

In order to get pages tagged with a certain tag in AEM query builder, we will do as this doc (https://helpx.adobe.com/experience-manager/6-2/sites/developing/using/querybuilder-api.html)
path=/content/...
type=cq:Page
tagid=marketing:interest/product
tagid.property=jcr:content/cq:tags
But how do we get pages that have the same tag title without using the whole tag's ID or full path above ?
For example
path=/content/...
type=cq:Page
tagtitle=product
tagid.property=jcr:content/cq:tags
You could use something like that:
JCR like:
path=/content/..
type=cq:Page
property=jcr:content/#cq:tags
property.value=%tagname
property.operation=like
This would search for cq:tags property with value that ends with "product".
See more about jcr:like function.
Another possible solution:
Full text search:
path=/content/somesite
type=cq:Page
fulltext.relPath=jcr:content/#cq:tags
fulltext=tagname
See more about jcr:contains function

reformat date that is pulled from database table

I have a website which uses smarty templates.
I have a table in my db called posts that has various columns, one being "date_added". I managed to have that displayed on the posts by editing one of the Smarty templates for "posts" however, the date format is YYYY-MM-DD.
Is there any easy way for me to change this? Perhaps with jQuery?
Ideally, I want to only show the abbreviated month, with the day positioned next it. This is for a blog style post, but this isn't WordPress.
Right now the smartytemplate the shows the date_added reads like this:
{$posts[i].date_added|stripslashes|nl2br}
Where posts is the table and date_added is a column in that table.
An exact example can be seen here in the top right corner of each post.
http://www.elegantthemes.com/preview/LightBright/
Does anyone have a good suggestion of how I can achieve the desired request?
If you are looking for a javascript solution, you can take a look at the incredible JS Library MomentJS. It is very lightweight and does numerous date and time formats.
http://momentjs.com/
Just include the minified script file in your HTML .
For your exact case, you would use momentJS as such:
First create the momentJS date object:
var moment_date = moment(date_from_database, "YYYY-MM-DD");
Then to display the date as you want:
var date_string = moment_date.format("MMM DD"); // ex. = "Mar 03"
More documentation here: http://momentjs.com/docs/#/displaying/
Then you can use your DOM manipulation library (JQuery for example) to place that string somewhere in your HTML
Good luck
- K