I wish to build a sql2 jcr query to find all pages under /content that contains this component, e.g /apps/platform/aem-core/components/content/form/form
I read https://wiki.magnolia-cms.com/display/WIKI/JCR+Query+Cheat+Sheet and tried something like below
My current attempt is something like SELECT * from [cq:Page] AS t WHERE t.contains('/apps/platform/aem-core/components/content/form/form')
But it won't work. Please suggest me a example to find all pages contains this component. Thanks
As #awd has mentioned in the comments, QueryBuilder provides better capabilities.
SQL2 however is not that bad, especially for someone with an inclination towards RDBMS !
The below query should fetch all the page paths using the component resourceType.
SELECT * FROM [cq:PageContent] AS s WHERE
ISDESCENDANTNODE(s,'/content') AND CONTAINS(s.[sling:resourceType],
'foundation/components/text')
You've got to use square brackets for properties with namespaces in them, for e.g: cq:template, sling:resourceType, etc
SELECT page.* FROM [cq:Page] AS page INNER JOIN [nt:base] AS component ON ISDESCENDANTNODE(component,page) WHERE ISDESCENDANTNODE(page, '/content') AND component.[sling:resourceType] = '/apps/platform/aem-core/components/content/form/form'
select * from nt:base where jcr:path like '/content/%' and [sling:resourceType] ='/apps/platform/aem-core/components/content/form/form'
Related
I want to exclude child nodes path from search path using querybuilder
for example - parent folder is /content/mysite/en
and subfolders are
/content/mysite/en/testfolder1
/content/mysite/en/testfolder2
I want query builder to write a query to exclude these paths
I already looked at this question -
AEM Query builder exclude a folder in search
but grouping paths and p.not=true doesn't seem to be working as expected
I know it's a bit tricky to write such a query using query builder ; so I am using JCR/SQL2 query -
using
SELECT * FROM [cq:Page]
WHERE ISDESCENDANTNODE(page,'/content/mysite/en')
AND CONTAINS(*, 'fulltext')
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder1')
AND NOT ISDESCENDANTNODE(page, '/content/mysite/en/testfolder2')
but the issue now is that We also want the search excerpt which is created automatically by querybuilder api's SearchResult's hit object -
hit.getExcerpt()
so is there a way I can get the excerpt using JCR/SQL2 query ?
OR is there a way I can build the exclude subfolder query using querybuilder; so that I can get excerpts from results? Both solutions will solve my case.
If anyone has experience in excluding subfolder query using querybuilder; or building search excerpt using JCR/SQL2 query; or any other idea/suggestion for this case; help will be much appreciated
Try path.exact=true Below is a example
without path.exact=true
type=cq:Page
path=/content/wkndmuzik/us/en
output:
With path.exact=true
type=cq:Page
path=/content/wkndmuzik/us/en
path.exact=true
Output:
path.exact=true : If true exact path is matched, if false all descendants are included.
For other predicates on querybuider api visit the blog of Hashim Khan
How to get specific content type document count in alfresco share UI using Lucene query?
I have tried to query in alfresco share UI Alfresco Lucene query. but it's only giving first 100 results.
Is there any best way to get only document count by specific content type or document count under specific alfresco site??
Please suggest if there is any other best and useful way.
Thanks in Advance.
The class PatchDAO has a method that returns the number of node with a given type:
/**
* Gets the total number of nodes which match the given Type QName.
*
* #param typeQName the qname to search for
* #return count of nodes that match the typeQName
*/
public long getCountNodesWithTypId(QName typeQName);
where typeQName is, of course, the QName of the type.
This method should return the total count and should be the most efficient.
UPDATE:
If you need the count on a specific site this method is not actually usable.
ResultSet result = searchService.query(, SearchService.LANGUAGE_LUCENE, "+PATH:\"/app:company_home/cm:" + + "/*\"" + " +TYPE:\"" + + "\"" );
You can change the parameters as per your need.
Thanks,
Kintu
Hitting the database directly is a very bad idea, so don't even start getting into that bad habit.
Using the Alfresco foundational Java API would require that the Java class be deployed to the server, which is a pain.
The easiest way to do this is to use OpenCMIS. You can run OpenCMIS code remotely, and you can use its paging result set to page through the query results, see Apache CMIS: Paging query result
This is the error I get.
16.03.2016 12:02:16.413 WARN [xxx.xxx.xx.xxx [1458147736268] GET /en/employees-leaders/employee-s-toolkit2/epd-update/epd-update-archives/caterpillar-news/upcoming-brand-webinarfocusonmarketing.html HTTP/1.1] com.day.cq.wcm.core.impl.LanguageManagerImpl Error while
retrieving language property. javax.jcr.AccessDeniedException: cannot
read item xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (alpha-numeric)
I am trying to locate the node in JCR using the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, which I believe is uuid, using a query in AEM.
Is the xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx actually a uuid?
How do I locate the source i.e node, causing the issue?
I tried running a sql with the above id in the jcr, but it returned no result.
//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')] order by #jcr:score descending
Any other insights would be much appreciated.
You don't need a query if you know the Node's UUID, just use the Session.getNodeByIdentifier(String id) method.
Your query is not SQL as you stated, it's XPATH. Is that a typo or did you run the query incorrectly?
It certainly looks like a UUID. You can query for the jcr:uuid property or you can continue doing a full text search.
XPATH:
/jcr:root//*[jcr:contains(., '91186155-45ad-474-9ad9-d5156a398629')]
/jcr:root//*[#jcr:uuid='91186155-45ad-474-9ad9-d5156a398629']
JCR-SQL2:
SELECT * FROM [nt:base] AS s WHERE contains(s.*, '91186155-45ad-474-9ad9-d5156a398629')
SELECT * FROM [nt:base] WHERE [jcr:uuid] = '91186155-45ad-474-9ad9-d5156a398629'
What read permissions does your account have? You're going to find a lot of results for a jcr:uuid query will be under /jcr:system/jcr:versionStorage.
Use QueryBuilderDebugger, (localhost:4502/libs/cq/search/content/querydebug.html) and run similar query as below to get the node for a given uuid:
property=jcr:uuid
property.value=e69b256e-a466-3730-866b-de22c82ab8ck
path=/home
type=rep:Group
p.limit=10
I have an issue to search with SOLR in following scenario,
I'd like to get all products within my favorite tag, categories and user. I want all products which created by my favorite user without any filter but products from favorite tag or categories must be filtered with in a selected location. I have tried as follows,
http://www.example.com:8983/solr/collection1/select?rows=10&start=0&wt=json&indent=true&sort=event_start_date asc&q=status:1 AND event_start_date:[2015-04-23T21:38:00Z TO *] AND ( tags:5539d77455061a650f96c67e OR category1_id:53d16fb28066a12606bbb5f2 OR category2_id:53d16fb28066a12606bbb5f2&fq={!geofilt d=40.2335}&pt=9.9312328,76.26730409999999&sfield=latlng) OR ( user_id:5465da1dc54d3c2a15000000 )
But its not working. Any body help me to find what's wrong with my query?
First of all you have a fq (filterquery clause) inside your query clause (check parenthesis) which is wrong.
fq={!geofilt d=40.2335}&pt=9.9312328,76.26730409999999&sfield=latlng
You can try things like puting the geofilt filter query OUTSIDE your main query with tests so it will be skipped if...
http://www.example.com:8983/solr/collection1/select?rows=10&start=0&wt=json&indent=true&sort=event_start_date asc&q=status:1 AND
event_start_date:[2015-04-23T21:38:00Z TO *] AND
(tags:5539d77455061a650f96c67e OR
category1_id:53d16fb28066a12606bbb5f2 OR
category2_id:53d16fb28066a12606bbb5f2) OR
(user_id:5465da1dc54d3c2a15000000)
&fq=user_id:5465da1dc54d3c2a15000000 OR
{!geofilt pt=9.9312328,76.26730409999999 sfield=latlng d=40.2335}
If user_id is 5465da1dc54d3c2a15000000 then the filterquery is already true so location part is skipped.
I am trying to untangle a complicated multi language Drupal site with custom SQL reports.
By poking around I bit I was able to construct this SQL statement which gives me all nodes and helps me find translation relationships.
SELECT node.nid as node_nid, node.language as node_language,
node.type as node_type, node.title as node_title,
node.tnid as node_tnid, node.status as node_status, url.src,
url.dst, url.language as url_language
FROM {node} as node
LEFT JOIN {url_alias} as url
ON url.src = CONCAT('node/', node.nid)
ORDER BY node_type, node_language, node.nid
Now I want to add 'permitted input formats' and publishing options for each node. Also list all menus and what they contain.
You may want to look at the views module, it can save you a lot of time and save you writing custom SQL.