title: CQ5 QueryBuilder returning no results when called from within a servlet
body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>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&amp;property=jcr%3acontent%2fmetadata%2fdam%3aPhysicalheightindpi&amp;property.value=96&amp;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 &gt;&gt; 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
  </code></pre>
  
  <p>And here is the output from querydebug.html:</p>
  
  <pre><code>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&amp;property=jcr%3acontent%2fmetadata%2fdam%3aPhysicalheightindpi&amp;property.value=96&amp;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 &gt;&gt; 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
  </code></pre>
  
  <p>Here is the code that's running the query in the servlet:</p>
  
  <pre><code>        Map&lt;String,String&gt; parms = new HashMap&lt;String,String&gt;();
  
          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 &amp;&amp; !nodeName.isEmpty() ) {
              parms.put(  "nodename", nodeName );
          }
  
          Query query = builder.createQuery( PredicateGroup.create( parms ), session );
  </code></pre>
  
  <p>From what I can see in the logs the queries being run for both the servlet and from the querydebug are identical so I'm at a loss as to why I'm getting no results back when running from the servlet. Any suggestions or pointers would be greatly appreciated.</p>