I am trying to find a way to search for a particular property and check if its value exceeding certain characters and print the complete node path where that property exists along with property value.
I was able to get the path detail using CRXDE sql 2 query like this
Can someone help me converting this to query builder query?
I tried these but looks like it is returning everything
or
If the SQL 2 query is working for you ; why are you looking for a query-builder query ? There wont be any kind of performance impact if you use any of these
Views
Replies
Total Likes
Still to answer your question
As far as my memory serves me right, there is no direct query in Query Builder. The max what you can do is to fetch the property nodes which you are searching and on the result set , you check the length of the values and print those nodes which meets your criteria .
JcrPropertyPredicateEvaluator ("The Adobe AEM Quickstart and Web Application.") will tell you what all properties are available for Property Predicate
Lets say I want to search for nodes which has a property = textIsRich under /content/geomtrixx. Then I would write a query like below
path=/content/geometrixx
type=nt:unstructured
property=textIsRich
property.operation=exists
Now I will write this query in my Java class and when the result set is returned , I will run through the values of this property and check for the length of the values and store those paths in a collection accordingly
// create query description as hash map (simplest way, same as form post)
Map<String, String> map = new HashMap<String, String>();
// create query description as hash map (simplest way, same as form post)
map.put("path", "/content/geometrixx");
map.put("type", "nt:unstructured");
map.put("property", "textIsRich");
map.put("property.operation", "exists");
Query query = builder.createQuery(PredicateGroup.create(map), session);
SearchResult result = query.getResult();
// iterating over the results
for (Hit hit : result.getHits()) {
String path = hit.getPath();
Resource resource = resourceResolver.getResource(path);
Node node = resource.adaptTo(Node.class);
// read property values
String textIsRich = node.getProperty("textIsRIch").getString();
//write the logic to check the length and then if it matches add that to a collection or write to a file
}
Views
Replies
Total Likes
thanks for your reply but i need some other information which are not coming out using sql and i can not export result set using CRX
Views
Replies
Total Likes
Can you let me know what exactly you are looking for ? May be we can help?
Thanks for your generosity.
can you help me updating my sql query to print videoId property value as well ?
doesn't matter , what i write but that sql is returning only full JCR path where that property exits but i need exact value of videoId property as second column.
for the export result issue, i will able to find workaround using chrome with little manual work but its ok for now.
Views
Replies
Total Likes
for (Hit hit : result.getHits()) {
String path = hit.getPath();
Resource resource = resourceResolver.getResource(path);
Node node = resource.adaptTo(Node.class);
// read property values
String videoIdValue= node.getProperty("videoId").getString();
//write the logic to check the length and then if it matches add that to a collection or write to a file
}
I can help you with the QueryBuilder API . Can you try like this ? This should fetch the value of the property.
Views
Replies
Total Likes
oh i know it will be fairly easy to get this through java class but unfortunately writing jive code is not an option for me and if there is no way to check property length in query builder query parameter , i will like to work on fixing sql query to print node path and property value where my condition returns true.
Views
Replies
Total Likes
AEM Query Structure:- Queries are always the backbone of any structure and from performance point of view. It becomes extremely important to write most optimized query. Lets decompose a query and see what all it consist of :-
Standard Predicates : Deep understanding of predicates is necessary if you want to Optimize any if your Search Query.
1 | ( @jcr :title = 'foo' or */ @jcr :title = 'foo' or */*/ @jcr :title = 'foo' ) |
Good Reference Read:- https://hashimkhan.in/2015/12/02/query-builder/ , http://www.aemcq5tutorials.com/tutorials/adobe-aem-cq5-tutorials/aem-query-builder/ and Query Builder API
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies