QueryBuilder returning 0 results
I have a servlet extended from SlingAllMethodsServlet that is using QueryBuilder to search for images in a path in our repository. When I execute the servlet, QueryBuilder returns 0 results, but when I run the same query from the querydebug.html provided by CQ it returns the expected results.
I've set the log level for com.day.cq.search to DEBUG in an attempt to find my error but I'm seeing the same output in the logger for both query attempts (except that the servlet request returns 0 results). Here is the log output from the servlet call:
18.12.2014 11:49:49.130 *INFO* [0:0:0:0:0:0:0:1 [1418921389129] 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
18.12.2014 11:49:49.132 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] 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
18.12.2014 11:49:49.133 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] 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}
]
18.12.2014 11:49:49.133 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] 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']
18.12.2014 11:49:49.155 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query took 22 ms
18.12.2014 11:49:49.164 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl >> xpath query returned 0 results (counted)
18.12.2014 11:49:49.165 *DEBUG* [0:0:0:0:0:0:0:1 [1418921389129] GET /libs/cq/search/content/createAssetPages HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl entire query execution took 32 ms
And here is the output from querydebug.html:
18.12.2014 11:49:56.611 *INFO* [0:0:0:0:0:0:0:1 [1418921396611] 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
18.12.2014 11:49:56.614 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] 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
18.12.2014 11:49:56.614 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] 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}
]
18.12.2014 11:49:56.615 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] 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']
18.12.2014 11:49:56.623 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl xpath query took 9 ms
18.12.2014 11:49:56.657 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl >> xpath query returned 206 results (counted)
18.12.2014 11:49:56.659 *DEBUG* [0:0:0:0:0:0:0:1 [1418921396611] GET /libs/cq/search/content/querydebug.html HTTP/1.1] com.day.cq.search.impl.builder.QueryImpl entire query execution took 45 ms
Here is the code that's running the query in the 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 );
As far as I can tell, the queries are identical so I have no clue as to why my servlet query returns no results. Any suggestions on what I may be doing wrong would be greatly appreciated!
