我有一个从SlingAllMethodsServlet扩展的servlet,它使用QueryBuilder在我们的存储库中的路径中搜索图像。当我执行servlet时,QueryBuilder返回0结果,但是当我从CQ提供的querydebug.html运行相同的查询时,它返回预期的结果。
我已将com.day.cq.search的日志级别设置为DEBUG以尝试查找我的错误,但我在记录器中看到两次查询尝试的相同输出(除了servlet请求返回0结果)。以下是servlet调用的日志输出:
GET /libs/cq/search/content/createAssetPages HTTP/1.1] cq5.mil.navy.history.util.impl.filters.LoggingFilter request for /libs/cq/search/content/createAssetPages, with selector null
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl executing query (URL):
path=%2fcontent%2fdam%2fnhhc%2four-collections%2fphotography&property=jcr%3acontent%2fmetadata%2fdam%3aPhysicalheightindpi&property.value=96&type=dam%3aAsset
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl executing query (predicate tree):
ROOT=group: [
{path=path: path=/content/dam/nhhc/our-collections/photography}
{property=property: value=96, property=jcr:content/metadata/dam:Physicalheightindpi}
{type=type: type=dam:Asset}
]
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query: /jcr:root/content/dam/nhhc/our-collections/photography//element(*, dam:Asset)[jcr:content/metadata/@dam:Physicalheightindpi = '96']
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query took 22 ms
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl >> xpath query returned 0 results (counted)
GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl entire query execution took 32 ms
以下是来自querydebug.html的输出:
GET /libs/cq/search/content/querydebug.html HTTP/1.1] cq5.mil.navy.history.util.impl.filters.LoggingFilter request for /libs/cq/search/content/querydebug, with selector null
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl executing query (URL):
path=%2fcontent%2fdam%2fnhhc%2four-collections%2fphotography&property=jcr%3acontent%2fmetadata%2fdam%3aPhysicalheightindpi&property.value=96&type=dam%3aAsset
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl executing query (predicate tree):
ROOT=group: [
{path=path: path=/content/dam/nhhc/our-collections/photography}
{property=property: value=96, property=jcr:content/metadata/dam:Physicalheightindpi}
{type=type: type=dam:Asset}
]
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query: /jcr:root/content/dam/nhhc/our-collections/photography//element(*, dam:Asset)[jcr:content/metadata/@dam:Physicalheightindpi = '96']
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query took 9 ms
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl >> xpath query returned 206 results (counted)
GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl entire query execution took 45 ms
以下是在servlet中运行查询的代码:
Map<String,String> parms = new HashMap<String,String>();
parms.put("type", "dam:Asset" );
parms.put( "path", "/content/dam/nhhc/our-collections/photography" );
// This search is only for low-res images so use the DPI value to keep from returning high-res images
parms.put( "property", "jcr:content/metadata/dam:Physicalheightindpi" );
parms.put( "property.value", "96" );
if( nodeName != null && !nodeName.isEmpty() ) {
parms.put( "nodename", nodeName );
}
Query query = builder.createQuery( PredicateGroup.create( parms ), session );
从日志中我可以看到,为servlet和来自querydebug运行的查询都是相同的,所以我不知道为什么从运行中运行时我没有得到任何结果。 servlet的。任何建议或指示将不胜感激。