mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-10131: SOLR: CMISQueryServices (old and open cmis) broken with SOLR (was WCMQS does not work, error on the page)
- not enough to fix WCMQS against SOLR git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30345 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -4,7 +4,21 @@
|
|||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
<bean id="search.CMISQueryService" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryServiceImpl" >
|
<bean id="search.CMISQueryService" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryServiceImpl" >
|
||||||
|
<property name="cmisDictionaryService">
|
||||||
|
<ref bean="CMISDictionaryService" />
|
||||||
|
</property>
|
||||||
|
<property name="cmisService">
|
||||||
|
<ref bean="CMISService" />
|
||||||
|
</property>
|
||||||
|
<property name="nodeService">
|
||||||
|
<ref bean="nodeService" />
|
||||||
|
</property>
|
||||||
|
<property name="alfrescoDictionaryService">
|
||||||
|
<ref bean="dictionaryService" />
|
||||||
|
</property>
|
||||||
|
<property name="solrQueryLanguage">
|
||||||
|
<ref bean="search.lucene.sql.alfresco" />
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -4,36 +4,11 @@
|
|||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
|
|
||||||
<bean id="search.OpenCMISQueryService" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryServiceImpl" >
|
<bean id="search.OpenCMISQueryService" class="org.alfresco.repo.search.impl.solr.SolrOpenCMISQueryServiceImpl" >
|
||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="search.lucene.sql.alfresco" class="org.alfresco.repo.search.impl.solr.SolrQueryLanguage" >
|
||||||
|
|
||||||
<bean id="search.lucene.sql.cmis.strict" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryLanguage" >
|
|
||||||
<property name="nodeDAO">
|
|
||||||
<ref bean="nodeDAO" />
|
|
||||||
</property>
|
|
||||||
<property name="permissionService">
|
|
||||||
<ref bean="permissionService" />
|
|
||||||
</property>
|
|
||||||
<property name="factories">
|
|
||||||
<list>
|
|
||||||
<ref bean="search.indexerAndSearcherFactory" />
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="name">
|
|
||||||
<value>cmis-strict</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="search.lucene.sql.alfresco" class="org.alfresco.repo.search.impl.solr.SolrCMISQueryLanguage" >
|
|
||||||
<property name="nodeDAO">
|
|
||||||
<ref bean="nodeDAO" />
|
|
||||||
</property>
|
|
||||||
<property name="permissionService">
|
|
||||||
<ref bean="permissionService" />
|
|
||||||
</property>
|
|
||||||
<property name="factories">
|
<property name="factories">
|
||||||
<list>
|
<list>
|
||||||
<ref bean="search.indexerAndSearcherFactory" />
|
<ref bean="search.indexerAndSearcherFactory" />
|
||||||
@@ -42,6 +17,23 @@
|
|||||||
<property name="name">
|
<property name="name">
|
||||||
<value>cmis-alfresco</value>
|
<value>cmis-alfresco</value>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="solrQueryHTTPClient">
|
||||||
|
<ref bean="search.solrQueryHTTPCLient" />
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="search.lucene.sql.cmis.strict" class="org.alfresco.repo.search.impl.solr.SolrQueryLanguage" >
|
||||||
|
<property name="factories">
|
||||||
|
<list>
|
||||||
|
<ref bean="search.indexerAndSearcherFactory" />
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
<property name="name">
|
||||||
|
<value>cmis-strict</value>
|
||||||
|
</property>
|
||||||
|
<property name="solrQueryHTTPClient">
|
||||||
|
<ref bean="search.solrQueryHTTPCLient" />
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
@@ -130,35 +130,6 @@
|
|||||||
<ref bean="search.solrQueryHTTPCLient" />
|
<ref bean="search.solrQueryHTTPCLient" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="search.lucene.sql.alfresco" class="org.alfresco.repo.search.impl.solr.SolrQueryLanguage" >
|
|
||||||
<property name="factories">
|
|
||||||
<list>
|
|
||||||
<ref bean="search.indexerAndSearcherFactory" />
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="name">
|
|
||||||
<value>cmis-alfrecso</value>
|
|
||||||
</property>
|
|
||||||
<property name="solrQueryHTTPClient">
|
|
||||||
<ref bean="search.solrQueryHTTPCLient" />
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="search.lucene.sql.cmis.strict" class="org.alfresco.repo.search.impl.solr.SolrQueryLanguage" >
|
|
||||||
<property name="factories">
|
|
||||||
<list>
|
|
||||||
<ref bean="search.indexerAndSearcherFactory" />
|
|
||||||
</list>
|
|
||||||
</property>
|
|
||||||
<property name="name">
|
|
||||||
<value>cmis-strict</value>
|
|
||||||
</property>
|
|
||||||
<property name="solrQueryHTTPClient">
|
|
||||||
<ref bean="search.solrQueryHTTPCLient" />
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="search.indexerAndSearcherFactory" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
|
<bean id="search.indexerAndSearcherFactory" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
|
||||||
<property name="proxyInterface">
|
<property name="proxyInterface">
|
||||||
|
@@ -22,7 +22,11 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
|
import org.alfresco.repo.search.impl.querymodel.QueryOptions;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.QueryOptions.Connective;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The options for a CMIS query
|
* The options for a CMIS query
|
||||||
@@ -39,6 +43,35 @@ public class CMISQueryOptions extends QueryOptions
|
|||||||
|
|
||||||
private CMISQueryMode queryMode = CMISQueryMode.CMS_STRICT;
|
private CMISQueryMode queryMode = CMISQueryMode.CMS_STRICT;
|
||||||
|
|
||||||
|
|
||||||
|
public static CMISQueryOptions create(SearchParameters searchParameters)
|
||||||
|
{
|
||||||
|
String sql = searchParameters.getQuery();
|
||||||
|
|
||||||
|
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
||||||
|
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
||||||
|
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
||||||
|
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
||||||
|
options.setSkipCount(searchParameters.getSkipCount());
|
||||||
|
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
||||||
|
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
||||||
|
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
||||||
|
{
|
||||||
|
options.setMaxItems(searchParameters.getLimit());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
options.setMaxItems(searchParameters.getMaxItems());
|
||||||
|
}
|
||||||
|
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
||||||
|
options.setLocales(searchParameters.getLocales());
|
||||||
|
options.setStores(searchParameters.getStores());
|
||||||
|
//options.setQuery(); Done on conbstruction
|
||||||
|
//options.setQueryMode(); Should set afterwards
|
||||||
|
options.setQueryParameterDefinitions(searchParameters.getQueryParameterDefinitions());
|
||||||
|
options.setDefaultFieldName(searchParameters.getDefaultFieldName());
|
||||||
|
return options;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Create a CMISQueryOptions instance with the default options other than the query and store ref.
|
* Create a CMISQueryOptions instance with the default options other than the query and store ref.
|
||||||
* The query will be run using the locale returned by I18NUtil.getLocale()
|
* The query will be run using the locale returned by I18NUtil.getLocale()
|
||||||
@@ -84,6 +117,33 @@ public class CMISQueryOptions extends QueryOptions
|
|||||||
{
|
{
|
||||||
this.queryMode = queryMode;
|
this.queryMode = queryMode;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SearchParameters getAsSearchParmeters()
|
||||||
|
{
|
||||||
|
SearchParameters searchParameters = new SearchParameters();
|
||||||
|
searchParameters.setDefaultFieldName(this.getDefaultFieldName());
|
||||||
|
searchParameters.setDefaultFTSFieldConnective(this.getDefaultFTSFieldConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||||
|
searchParameters.setDefaultFTSOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||||
|
searchParameters.setDefaultOperator(this.getDefaultFTSConnective() == Connective.OR ? SearchParameters.Operator.OR : SearchParameters.Operator.AND);
|
||||||
|
searchParameters.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
|
||||||
|
if(this.getMaxItems() > 0)
|
||||||
|
{
|
||||||
|
searchParameters.setLimit(this.getMaxItems());
|
||||||
|
searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
|
||||||
|
searchParameters.setMaxItems(this.getMaxItems());
|
||||||
|
}
|
||||||
|
searchParameters.setMaxPermissionChecks(this.getMaxPermissionChecks());
|
||||||
|
searchParameters.setMaxPermissionCheckTimeMillis(this.getMaxPermissionCheckTimeMillis());
|
||||||
|
searchParameters.setMlAnalaysisMode(this.getMlAnalaysisMode());
|
||||||
|
//searchParameters.setNamespace() TODO: Fix
|
||||||
|
//searchParameters.setPermissionEvaluation()
|
||||||
|
searchParameters.setQuery(this.getQuery());
|
||||||
|
searchParameters.setSkipCount(this.getSkipCount());
|
||||||
|
|
||||||
|
return searchParameters;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -79,25 +79,7 @@ public class LuceneAlfrescoFtsQueryLanguage extends AbstractLuceneQueryLanguage
|
|||||||
AlfrescoFunctionEvaluationContext context = new AlfrescoFunctionEvaluationContext(admLuceneSearcher.getNamespacePrefixResolver(), admLuceneSearcher.getDictionaryService(),
|
AlfrescoFunctionEvaluationContext context = new AlfrescoFunctionEvaluationContext(admLuceneSearcher.getNamespacePrefixResolver(), admLuceneSearcher.getDictionaryService(),
|
||||||
searchParameters.getNamespace());
|
searchParameters.getNamespace());
|
||||||
|
|
||||||
QueryOptions options = new QueryOptions(searchParameters.getQuery(), null);
|
QueryOptions options = QueryOptions.create(searchParameters);
|
||||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
|
||||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setSkipCount(searchParameters.getSkipCount());
|
|
||||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
|
||||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
|
||||||
options.setDefaultFieldName(searchParameters.getDefaultFieldName());
|
|
||||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getLimit());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getMaxItems());
|
|
||||||
}
|
|
||||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
|
||||||
options.setLocales(searchParameters.getLocales());
|
|
||||||
options.setStores(searchParameters.getStores());
|
|
||||||
|
|
||||||
FTSParser.Mode mode;
|
FTSParser.Mode mode;
|
||||||
|
|
||||||
@@ -109,7 +91,7 @@ public class LuceneAlfrescoFtsQueryLanguage extends AbstractLuceneQueryLanguage
|
|||||||
{
|
{
|
||||||
mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
|
mode = FTSParser.Mode.DEFAULT_DISJUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
Constraint constraint = FTSQueryParser.buildFTS(ftsExpression, factory, context, null, null, mode, options.getDefaultFTSFieldConnective(),
|
Constraint constraint = FTSQueryParser.buildFTS(ftsExpression, factory, context, null, null, mode, options.getDefaultFTSFieldConnective(),
|
||||||
searchParameters.getQueryTemplates(), options.getDefaultFieldName());
|
searchParameters.getQueryTemplates(), options.getDefaultFieldName());
|
||||||
org.alfresco.repo.search.impl.querymodel.Query query = factory.createQuery(null, null, constraint, buildOrderings(factory, searchParameters));
|
org.alfresco.repo.search.impl.querymodel.Query query = factory.createQuery(null, null, constraint, buildOrderings(factory, searchParameters));
|
||||||
|
@@ -58,30 +58,8 @@ public class LuceneAlfrescoSqlQueryLanguage extends AbstractLuceneQueryLanguage
|
|||||||
|
|
||||||
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
||||||
{
|
{
|
||||||
String sql = searchParameters.getQuery();
|
CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
|
||||||
|
|
||||||
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
|
||||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
|
||||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setSkipCount(searchParameters.getSkipCount());
|
|
||||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
|
||||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
|
||||||
options.setDefaultFieldName(searchParameters.getDefaultFieldName());
|
|
||||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getLimit());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getMaxItems());
|
|
||||||
}
|
|
||||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
|
||||||
options.setLocales(searchParameters.getLocales());
|
|
||||||
options.setStores(searchParameters.getStores());
|
|
||||||
|
|
||||||
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
|
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
|
||||||
|
|
||||||
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -58,29 +58,8 @@ public class LuceneCmisStrictSqlQueryLanguage extends AbstractLuceneQueryLanguag
|
|||||||
|
|
||||||
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
||||||
{
|
{
|
||||||
String sql = searchParameters.getQuery();
|
CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
|
||||||
|
|
||||||
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
|
||||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
|
||||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR : Connective.AND);
|
|
||||||
options.setSkipCount(searchParameters.getSkipCount());
|
|
||||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
|
||||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
|
||||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getLimit());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getMaxItems());
|
|
||||||
}
|
|
||||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
|
||||||
options.setLocales(searchParameters.getLocales());
|
|
||||||
options.setStores(searchParameters.getStores());
|
|
||||||
|
|
||||||
options.setQueryMode(CMISQueryMode.CMS_STRICT);
|
options.setQueryMode(CMISQueryMode.CMS_STRICT);
|
||||||
|
|
||||||
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,31 +59,8 @@ public class LuceneOpenCMISAlfrescoSqlQueryLanguage extends AbstractLuceneQueryL
|
|||||||
|
|
||||||
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
||||||
{
|
{
|
||||||
String sql = searchParameters.getQuery();
|
CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
|
||||||
|
|
||||||
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
|
||||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
|
||||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR
|
|
||||||
: Connective.AND);
|
|
||||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR
|
|
||||||
: Connective.AND);
|
|
||||||
options.setSkipCount(searchParameters.getSkipCount());
|
|
||||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
|
||||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
|
||||||
options.setDefaultFieldName(searchParameters.getDefaultFieldName());
|
|
||||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getLimit());
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getMaxItems());
|
|
||||||
}
|
|
||||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
|
||||||
options.setLocales(searchParameters.getLocales());
|
|
||||||
options.setStores(searchParameters.getStores());
|
|
||||||
|
|
||||||
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
|
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
|
||||||
|
|
||||||
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -59,30 +59,8 @@ public class LuceneOpenCMISStrictSqlQueryLanguage extends AbstractLuceneQueryLan
|
|||||||
|
|
||||||
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
public ResultSet executeQuery(SearchParameters searchParameters, ADMLuceneSearcherImpl admLuceneSearcher)
|
||||||
{
|
{
|
||||||
String sql = searchParameters.getQuery();
|
CMISQueryOptions options = CMISQueryOptions.create(searchParameters);
|
||||||
|
|
||||||
CMISQueryOptions options = new CMISQueryOptions(sql, searchParameters.getStores().get(0));
|
|
||||||
options.setIncludeInTransactionData(!searchParameters.excludeDataInTheCurrentTransaction());
|
|
||||||
options.setDefaultFTSConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR
|
|
||||||
: Connective.AND);
|
|
||||||
options.setDefaultFTSFieldConnective(searchParameters.getDefaultOperator() == SearchParameters.Operator.OR ? Connective.OR
|
|
||||||
: Connective.AND);
|
|
||||||
options.setSkipCount(searchParameters.getSkipCount());
|
|
||||||
options.setMaxPermissionChecks(searchParameters.getMaxPermissionChecks());
|
|
||||||
options.setMaxPermissionCheckTimeMillis(searchParameters.getMaxPermissionCheckTimeMillis());
|
|
||||||
if (searchParameters.getLimitBy() == LimitBy.FINAL_SIZE)
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getLimit());
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
options.setMaxItems(searchParameters.getMaxItems());
|
|
||||||
}
|
|
||||||
options.setMlAnalaysisMode(searchParameters.getMlAnalaysisMode());
|
|
||||||
options.setLocales(searchParameters.getLocales());
|
|
||||||
options.setStores(searchParameters.getStores());
|
|
||||||
|
|
||||||
options.setQueryMode(CMISQueryMode.CMS_STRICT);
|
options.setQueryMode(CMISQueryMode.CMS_STRICT);
|
||||||
|
|
||||||
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
return new ResultSetSPIWrapper<CMISResultSetRow, CMISResultSetMetaData>(cmisQueryService.query(options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,12 +18,30 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.search.impl.solr;
|
package org.alfresco.repo.search.impl.solr;
|
||||||
|
|
||||||
import org.alfresco.opencmis.search.CMISQueryOptions;
|
import java.util.HashMap;
|
||||||
import org.alfresco.opencmis.search.CMISQueryService;
|
import java.util.Map;
|
||||||
import org.alfresco.opencmis.search.CMISResultSet;
|
import java.util.Set;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
|
import org.alfresco.cmis.CMISDictionaryService;
|
||||||
import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
|
import org.alfresco.cmis.CMISJoinEnum;
|
||||||
|
import org.alfresco.cmis.CMISQueryEnum;
|
||||||
|
import org.alfresco.cmis.CMISQueryOptions;
|
||||||
|
import org.alfresco.cmis.CMISQueryService;
|
||||||
|
import org.alfresco.cmis.CMISResultSet;
|
||||||
|
import org.alfresco.cmis.CMISScope;
|
||||||
|
import org.alfresco.cmis.CMISServices;
|
||||||
|
import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode;
|
||||||
|
import org.alfresco.cmis.search.CMISQueryParser;
|
||||||
|
import org.alfresco.cmis.search.CMISResultSetImpl;
|
||||||
|
import org.alfresco.cmis.search.CmisFunctionEvaluationContext;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.Query;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andy
|
* @author Andy
|
||||||
@@ -31,45 +49,126 @@ import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
|
|||||||
*/
|
*/
|
||||||
public class SolrCMISQueryServiceImpl implements CMISQueryService
|
public class SolrCMISQueryServiceImpl implements CMISQueryService
|
||||||
{
|
{
|
||||||
|
private CMISServices cmisService;
|
||||||
|
|
||||||
|
private SolrQueryLanguage solrQueryLanguage;
|
||||||
|
|
||||||
|
private CMISDictionaryService cmisDictionaryService;
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private DictionaryService alfrescoDictionaryService;
|
||||||
|
|
||||||
|
public void setCmisService(CMISServices cmisService)
|
||||||
|
{
|
||||||
|
this.cmisService = cmisService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSolrQueryLanguage(SolrQueryLanguage solrQueryLanguage)
|
||||||
|
{
|
||||||
|
this.solrQueryLanguage = solrQueryLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
|
||||||
|
{
|
||||||
|
this.cmisDictionaryService = cmisDictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService)
|
||||||
|
{
|
||||||
|
this.alfrescoDictionaryService = alfrescoDictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.opencmis.search.CMISQueryService#query(org.alfresco.opencmis.search.CMISQueryOptions)
|
* @see org.alfresco.cmis.CMISQueryService#query(org.alfresco.cmis.CMISQueryOptions)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CMISResultSet query(CMISQueryOptions options)
|
public CMISResultSet query(CMISQueryOptions options)
|
||||||
{
|
{
|
||||||
// TODO Auto-generated method stub
|
ResultSet rs = solrQueryLanguage.executeQuery(options.getAsSearchParmeters(), null);
|
||||||
return null;
|
|
||||||
|
CMISJoinEnum joinSupport = getJoinSupport();
|
||||||
|
if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
|
||||||
|
{
|
||||||
|
joinSupport = CMISJoinEnum.INNER_JOIN_SUPPORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser
|
||||||
|
|
||||||
|
CMISScope[] 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);
|
||||||
|
Query query = parser.parse(new LuceneQueryModelFactory(), functionContext);
|
||||||
|
|
||||||
|
Map<String, ResultSet> wrapped = new HashMap<String, ResultSet>();
|
||||||
|
for (Set<String> group : query.getSource().getSelectorGroups(functionContext))
|
||||||
|
{
|
||||||
|
for (String selector : group)
|
||||||
|
{
|
||||||
|
wrapped.put(selector, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LimitBy limitBy = null;
|
||||||
|
limitBy = rs.getResultSetMetaData().getLimitedBy();
|
||||||
|
|
||||||
|
CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService);
|
||||||
|
return cmis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.alfresco.opencmis.search.CMISQueryService#query(java.lang.String, org.alfresco.service.cmr.repository.StoreRef)
|
* @see org.alfresco.cmis.CMISQueryService#query(java.lang.String)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CMISResultSet query(String query, StoreRef storeRef)
|
public CMISResultSet query(String query)
|
||||||
{
|
{
|
||||||
CMISQueryOptions options = new CMISQueryOptions(query, storeRef);
|
CMISQueryOptions options = new CMISQueryOptions(query, cmisService.getDefaultRootStoreRef());
|
||||||
return query(options);
|
return query(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPwcSearchable()
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.cmis.CMISQueryService#getQuerySupport()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CMISQueryEnum getQuerySupport()
|
||||||
{
|
{
|
||||||
return true;
|
return CMISQueryEnum.BOTH_COMBINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.cmis.CMISQueryService#getJoinSupport()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CMISJoinEnum getJoinSupport()
|
||||||
|
{
|
||||||
|
return CMISJoinEnum.NO_JOIN_SUPPORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.cmis.CMISQueryService#getPwcSearchable()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean getPwcSearchable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.cmis.CMISQueryService#getAllVersionsSearchable()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
public boolean getAllVersionsSearchable()
|
public boolean getAllVersionsSearchable()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CapabilityQuery getQuerySupport()
|
|
||||||
{
|
|
||||||
return CapabilityQuery.BOTHCOMBINED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CapabilityJoin getJoinSupport()
|
|
||||||
{
|
|
||||||
return CapabilityJoin.NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.search.impl.solr;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
import org.alfresco.cmis.CMISScope;
|
||||||
|
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
|
||||||
|
import org.alfresco.opencmis.search.CMISQueryOptions;
|
||||||
|
import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
|
||||||
|
import org.alfresco.opencmis.search.CMISQueryParser;
|
||||||
|
import org.alfresco.opencmis.search.CMISQueryService;
|
||||||
|
import org.alfresco.opencmis.search.CMISResultSet;
|
||||||
|
import org.alfresco.opencmis.search.CmisFunctionEvaluationContext;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.Query;
|
||||||
|
import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory;
|
||||||
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
|
import org.alfresco.service.cmr.search.LimitBy;
|
||||||
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
|
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||||
|
import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
|
||||||
|
import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Andy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SolrOpenCMISQueryServiceImpl implements CMISQueryService
|
||||||
|
{
|
||||||
|
|
||||||
|
private SolrQueryLanguage solrQueryLanguage;
|
||||||
|
|
||||||
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private DictionaryService alfrescoDictionaryService;
|
||||||
|
|
||||||
|
private CMISDictionaryService cmisDictionaryService;
|
||||||
|
|
||||||
|
|
||||||
|
public void setSolrQueryLanguage(SolrQueryLanguage solrQueryLanguage)
|
||||||
|
{
|
||||||
|
this.solrQueryLanguage = solrQueryLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodeService(NodeService nodeService)
|
||||||
|
{
|
||||||
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService)
|
||||||
|
{
|
||||||
|
this.alfrescoDictionaryService = alfrescoDictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
|
||||||
|
{
|
||||||
|
this.cmisDictionaryService = cmisDictionaryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.opencmis.search.CMISQueryService#query(org.alfresco.opencmis.search.CMISQueryOptions)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CMISResultSet query(CMISQueryOptions options)
|
||||||
|
{
|
||||||
|
ResultSet rs = solrQueryLanguage.executeQuery(options.getAsSearchParmeters(), null);
|
||||||
|
|
||||||
|
CapabilityJoin joinSupport = getJoinSupport();
|
||||||
|
if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
|
||||||
|
{
|
||||||
|
joinSupport = CapabilityJoin.INNERONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
Query query = parser.parse(new LuceneQueryModelFactory(), functionContext);
|
||||||
|
|
||||||
|
Map<String, ResultSet> wrapped = new HashMap<String, ResultSet>();
|
||||||
|
for (Set<String> group : query.getSource().getSelectorGroups(functionContext))
|
||||||
|
{
|
||||||
|
for (String selector : group)
|
||||||
|
{
|
||||||
|
wrapped.put(selector, rs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LimitBy limitBy = null;
|
||||||
|
limitBy = rs.getResultSetMetaData().getLimitedBy();
|
||||||
|
|
||||||
|
CMISResultSet cmis = new CMISResultSet(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService);
|
||||||
|
return cmis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.opencmis.search.CMISQueryService#query(java.lang.String, org.alfresco.service.cmr.repository.StoreRef)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CMISResultSet query(String query, StoreRef storeRef)
|
||||||
|
{
|
||||||
|
CMISQueryOptions options = new CMISQueryOptions(query, storeRef);
|
||||||
|
return query(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPwcSearchable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getAllVersionsSearchable()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CapabilityQuery getQuerySupport()
|
||||||
|
{
|
||||||
|
return CapabilityQuery.BOTHCOMBINED;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CapabilityJoin getJoinSupport()
|
||||||
|
{
|
||||||
|
return CapabilityJoin.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user