final QueryResponse querySolr(String collection, SolrDataQuery query, @Nullable Class<?> clazz, @Nullable RequestMethod requestMethod) { Assert.notNull(query, "Query must not be 'null'"); SolrQuery solrQuery = constructQuery(query, clazz); if (clazz != null) { SolrPersistentEntity<?> persistedEntity = mappingContext.getRequiredPersistentEntity(clazz); if (persistedEntity.hasScoreProperty()) { solrQuery.setIncludeScore(true); } } LOGGER.debug("Executing query '{}' against solr.", solrQuery); return executeSolrQuery(collection, solrQuery, getSolrRequestMethod(requestMethod)); }
@Override public long count(String collection, SolrDataQuery query, @Nullable Class<?> domainType, RequestMethod method) { Assert.notNull(collection, "Collection must not be null!"); Assert.notNull(query, "Query must not be 'null'."); Assert.notNull(method, "Method must not be 'null'."); return execute(solrClient -> { SolrQuery solrQuery = constructQuery(query, domainType); solrQuery.clearSorts(); solrQuery.setStart(0); solrQuery.setRows(0); return solrClient.query(collection, solrQuery, getSolrRequestMethod(method)).getResults().getNumFound(); }); }