We have a requirement for filtering content fragment by created date and last modified date, which are stored in the _metadata. Since it's an out of the box field, we are unable to apply any filters against it. Is there a workaround for this? Our other option is to filter dates after querying the entire data, but we'd like to avoid this if possible.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
dear, krati, We have a requirement for filtering content fragment by start date and end date, also OR title, content, but it is not work, colud you help to suggest for me ?
Hi @OneCh
Can you please write the query here, so that it can be checked for syntax error.
Also, please define the filter in text, that you are trying to put in, I see three logical test here, but not sure, where do you want to apply logOp : Or / logOp and
query landingSearch($offset: Int, $limit: Int, $lang: String, $val: String, $nowDate:Calendar) {
activityList(
offset: $offset
limit: $limit
sort: "publishTime DESC"
_locale: $lang
filter: {
# publishStartTime and publishEndTime
publishStartTime:{_expressions:[{value:$nowDate, _operator:BEFORE}]}
publishEndTime:{_expressions:[{value:$nowDate, _operator:AFTER}]}
_logOp : OR
# title OR content
title: {_expressions: [{value: $val, _operator: CONTAINS,_ignoreCase:true}]},
content: {plaintext: {_expressions: [{value: $val, _operator: CONTAINS,_ignoreCase:true}]}}
}
) {
items {
_path
title
}
}
}
thx
can you also share what value are being passes for these:
$offset: Int, $limit: Int, $lang: String, $val: String, $nowDate:Calendar
Basically the query is working fine syntactically. However, your expectations out of query largely depends upon the Data you have and logic you are trying to apply.
So I need above info and sample data.
@OneCh
yes,
offset : 0 , limit : 10 , val : "test", nowDate : 2023-12-18T14:56:00.000+08:00
by the way, my graphql logic is : (publishStartTime and publishEndTime) OR (title OR content) ,but i don't know how to wirt on graphql
Alright, below is my observation:
Please validate your date data, if you are still not getting the results
sorry, @krati_garg , my graphql logic is : (publishStartTime < nowDate < publishEndTime) AND (title OR content), how to wirt on graphql?
Hi @dsong12 ,
From what I understand working on the GraphQL query editor in AEM is that the _metadata is only available in the ModelResults Type and not the ModelFilter Type, this means that you would not be able to filter your content fragments based on the 'created by' and 'last modified' date since they are a part of _metadata.
You can also check and confirm this in the Docs section in your GraphQL query editor.
Hi @OneCh, after doing some hands-on on this one, I noticed that the sort takes up String value of a model attribute, but the problem now arises that there's no way to exactly target the last modified date because the query and json response pair as follows,
_metadata{
calendarMetadata{
name
value
}
"_metadata": {
"calendarMetadata": [
{
"name": "jcr:created",
"value": "2023-09-25T12:39:11.047+05:30"
},
{
"name": "cq:lastPublished",
"value": "2023-09-26T11:55:04.939Z"
},
{
"name": "cq:lastModified",
"value": "2023-09-26T11:55:04.486Z"
}
]
and if I try to sort it based on this sort in the query,
sort:"_metadata.calendarMetadata.name"
it actually sorts the content fragments based on the jcr:created property.
thanks very much, i try to use other way to do that
@dsong12 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Hello! Did you find any workaround for your problem? I have same issues here
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies