AEM Query

本文深入探讨了Adobe Experience Manager (AEM)中使用SQL2和查询构建器API进行内容搜索的方法。详细介绍了如何通过构建查询语句来筛选特定路径下含有关键词的节点,以及如何利用查询构建器API创建复杂的查询条件,实现更精准的内容检索。

AEM Query

Two ways about Query

SQL2:

String sql = "SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([" + searchPath + "]) and (CONTAINS('"

+ titleProperty + "', '" + keywords + "') or CONTAINS('"

+ titleDesc + "', '" + keywords + "'))";

private QueryResult searchResult(Session session, String sql) {

QueryResult result = null;

try {

QueryManager queryManager = session.getWorkspace().getQueryManager();

Query query = queryManager.createQuery(sql, Query.JCR_SQL2);

result = query.execute();

} catch (Exception e) {

e.printStackTrace();

}

return result;

}

 

Query:

private JSONObject getGlobalSearch(SlingHttpServletRequest request, Session session, String searchPath,

String keywords, JSONObject object){

         if(keywords.equals("")){

         keywords = "*";

         }

         else{

         keywords = "*"+keywords+"*";

         }

         String fulltextSearchTerm = keywords;

         // 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)

//         path=/main/path/where

//         group.1_property=myProperty

//         group.1_property.operation=exists

//         group.1_property.value=true

//         2_group.p.or=true

//         2_group.p.not=true

//         2_group.3_path=/main/path/where/first/you/donot/want/to/search

//         2_group.4_path=/main/path/where/second/you/donot/want/to/search

                      

         

         map.put("path", "/content/studyconnect/us/en");

         map.put("type", "cq:page");

         map.put("group.p.or", "true"); // combine this group with OR

         map.put("group.1_fulltext", fulltextSearchTerm);

//         map.put("group.1_fulltext.relPath", "jcr:content");

         map.put("group.1_fulltext.operation", "like");

//         map.put("group.2_fulltext", fulltextSearchTerm);

//         map.put("group.2_fulltext.relPath", "jcr:content/@cq:tags");

//         map.put("2_group.p.or", "false");

//         map.put("2_group.p.not", "true");

         

//         map.put("2_group.3_property", "jcr:createdBy");

//         map.put("2_group.3_property.value", fulltextSearchTerm);

//         map.put("2_group.3_property.operation", "not");

//         2_group.3_path=/main/path/where/first/you/donot/want/to/search

//         2_group.4_path=/main/path/where/second/you/donot/want/to/search

         

         // can be done in map or with Query methods

//         map.put("p.offset", "0"); // same as query.setStart(0) below

         map.put("p.limit", "-1");

                           

         Query query = builder.createQuery(PredicateGroup.create(map), session);

 

//         query.setStart(0);

//         query.setHitsPerPage(-1);

 

         SearchResult result = query.getResult();

         if (result != null) {

         List<JSONObject> glossaries = new ArrayList<>();

         Iterator<Node> nodes  = result.getNodes();

         try{

         while (nodes.hasNext()) {

         Node node = nodes.next();

         JSONObject obj = new JSONObject();

         obj.put("path", node.getPath());

         glossaries.add(obj);

         }

         object.put("glossaries", glossaries);

         }catch(Exception e){

         e.printStackTrace();

         }

         }

         return object;

}

fulltext does not search with system properties, Example: jcr:createdBy

参考:

https://helpx.adobe.com/experience-manager/using/using-query-builder-servlet.html

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/search/querybuilder/impl/SampleQueryBuilder.java

https://gist.github.com/floriankraft/8b3720464318cd5cd9e2

https://hashimkhan.in/2017/10/09/digest-the-query-builder-api-aem-search-tips/

转载于:https://my.oschina.net/slightScenery/blog/1923163

【负荷预测】基于VMD-CNN-LSTM的负荷预测研究(Python代码实现)内容概要:本文介绍了基于变分模态分解(VMD)、卷积神经网络(CNN)和长短期记忆网络(LSTM)相结合的VMD-CNN-LSTM模型在负荷预测中的研究与应用,采用Python代码实现。该方法首先利用VMD对原始负荷数据进行分解,降低序列复杂性并提取不同频率的模态分量;随后通过CNN提取各模态的局部特征;最后由LSTM捕捉时间序列的长期依赖关系,实现高精度的负荷预测。该模型有效提升了预测精度,尤其适用于非平稳、非线性的电力负荷数据,具有较强的鲁棒性和泛化能力。; 适合人群:具备一定Python编程基础和深度学习背景,从事电力系统、能源管理或时间序列预测相关研究的科研人员及工程技术人员,尤其适合研究生、高校教师及电力行业从业者。; 使用场景及目标:①应用于日前、日内及实时负荷预测场景,支持智慧电网调度与能源优化管理;②为研究复合型深度学习模型在非线性时间序列预测中的设计与实现提供参考;③可用于学术复现、课题研究或实际项目开发中提升预测性能。; 阅读建议:建议读者结合提供的Python代码,深入理解VMD信号分解机制、CNN特征提取原理及LSTM时序建模过程,通过实验调试参数(如VMD的分解层数K、惩罚因子α等)优化模型性能,并可进一步拓展至风电、光伏等其他能源预测领域。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值