use of org.alfresco.service.cmr.search.QueryConsistency in project alfresco-repository by Alfresco.
the class CMISQueryServiceImpl method executeQueryUsingEngine.
private Pair<Query, QueryEngineResults> executeQueryUsingEngine(QueryEngine queryEngine, CMISQueryOptions options) {
CapabilityJoin joinSupport = getJoinSupport();
if (options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS) {
joinSupport = CapabilityJoin.INNERANDOUTER;
}
// TODO: Refactor to avoid duplication of valid scopes here and in
// CMISQueryParser
BaseTypeId[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(cmisDictionaryService);
functionContext.setNodeService(nodeService);
functionContext.setValidScopes(validScopes);
CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
QueryConsistency queryConsistency = options.getQueryConsistency();
if (queryConsistency == QueryConsistency.DEFAULT) {
options.setQueryConsistency(QueryConsistency.EVENTUAL);
}
Query query = parser.parse(queryEngine.getQueryModelFactory(), functionContext);
QueryEngineResults queryEngineResults = queryEngine.executeQuery(query, options, functionContext);
return new Pair<Query, QueryEngineResults>(query, queryEngineResults);
}
use of org.alfresco.service.cmr.search.QueryConsistency in project alfresco-repository by Alfresco.
the class DbOrIndexSwitchingQueryLanguage method executeQuery.
public ResultSet executeQuery(SearchParameters searchParameters) {
QueryConsistency consistency = searchParameters.getQueryConsistency();
if (consistency == QueryConsistency.DEFAULT) {
consistency = queryConsistency;
}
switch(consistency) {
case EVENTUAL:
if (indexQueryLanguage != null) {
if (logger.isDebugEnabled()) {
logger.debug("Using SOLR query: " + dbQueryLanguage.getName() + " for " + searchParameters);
}
StopWatch stopWatch = new StopWatch("index only");
stopWatch.start();
ResultSet results = indexQueryLanguage.executeQuery(searchParameters);
stopWatch.stop();
if (logger.isDebugEnabled()) {
logger.debug("SOLR returned " + results.length() + " results in " + stopWatch.getLastTaskTimeMillis() + "ms");
}
return results;
} else {
throw new QueryModelException("No query language available");
}
case TRANSACTIONAL:
if (dbQueryLanguage != null) {
if (logger.isDebugEnabled()) {
logger.debug("Trying db query for " + dbQueryLanguage.getName() + " for " + searchParameters);
}
StopWatch stopWatch = new StopWatch("database only");
stopWatch.start();
ResultSet results = dbQueryLanguage.executeQuery(flattenDBQuery(searchParameters));
stopWatch.stop();
if (logger.isDebugEnabled()) {
logger.debug("DB returned " + results.length() + " results in " + stopWatch.getLastTaskTimeMillis() + "ms");
}
return results;
} else {
throw new QueryModelException("No query language available");
}
case HYBRID:
if (!hybridEnabled) {
throw new DisabledFeatureException("Hybrid query is disabled.");
}
return executeHybridQuery(searchParameters);
case DEFAULT:
case TRANSACTIONAL_IF_POSSIBLE:
default:
StopWatch stopWatch = new StopWatch("DB if possible");
// SEARCH-347, exclude TMDQ calls if faceting present.
if (dbQueryLanguage != null && !searchParameters.hasFaceting()) {
try {
if (logger.isDebugEnabled()) {
logger.debug("Trying db query for " + dbQueryLanguage.getName() + " for " + searchParameters);
}
stopWatch.start();
ResultSet results = dbQueryLanguage.executeQuery(flattenDBQuery(searchParameters));
stopWatch.stop();
if (logger.isDebugEnabled()) {
logger.debug("DB returned " + results.length() + " results in " + stopWatch.getLastTaskTimeMillis() + "ms");
}
return results;
} catch (QueryModelException qme) {
if (stopWatch.isRunning()) {
stopWatch.stop();
}
// MNT-10323: Logging configuration on JBoss leads to clogging of the log with a lot of these errors because of INFO level when WQS module is installed
if (logger.isDebugEnabled()) {
logger.debug("DB query failed for " + dbQueryLanguage.getName() + " for " + searchParameters, qme);
}
if (indexQueryLanguage != null) {
if (logger.isDebugEnabled()) {
logger.debug("Using SOLR query: " + dbQueryLanguage.getName() + " for " + searchParameters);
}
stopWatch.start();
ResultSet results = indexQueryLanguage.executeQuery(searchParameters);
stopWatch.stop();
if (logger.isDebugEnabled()) {
logger.debug("SOLR returned " + results.length() + " results in " + stopWatch.getLastTaskTimeMillis() + "ms");
}
return results;
}
}
} else {
if (indexQueryLanguage != null) {
if (logger.isDebugEnabled()) {
logger.debug("(No DB QL) Using SOLR query: " + "dbQueryLanguage==null" + " for " + searchParameters);
}
stopWatch.start();
ResultSet results = indexQueryLanguage.executeQuery(searchParameters);
stopWatch.stop();
if (logger.isDebugEnabled()) {
logger.debug("SOLR returned " + results.length() + " results in " + stopWatch.getLastTaskTimeMillis() + "ms");
}
return results;
}
}
throw new QueryModelException("No query language available");
}
}
Aggregations