Merged DEV to HEAD:

30289, 30366, 30381, 30607: (record-only)
    30621, 30658, 30674, 30689, 30700: MT-aware Solr (THOR-129) - enabler only (subject to QA)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31975 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2011-11-15 12:02:28 +00:00
parent fa9b63c5ff
commit 5c2a68bdd2
9 changed files with 155 additions and 90 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -23,9 +23,7 @@ import org.alfresco.repo.search.IndexerException;
import org.alfresco.repo.search.QueryRegisterComponent;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.search.impl.NoActionIndexer;
import org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl;
import org.alfresco.repo.search.impl.lucene.AbstractIndexerAndSearcher;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -43,7 +41,6 @@ public class SolrIndexerAndSearcherFactory extends AbstractIndexerAndSearcher
private NamespacePrefixResolver namespacePrefixResolver;
private NodeService nodeService;
private QueryRegisterComponent queryRegister;
private TenantService tenantService;
private String baseUrl;
public DictionaryService getDictionaryService()
@@ -86,16 +83,6 @@ public class SolrIndexerAndSearcherFactory extends AbstractIndexerAndSearcher
this.queryRegister = queryRegister;
}
public TenantService getTenantService()
{
return tenantService;
}
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public String getBaseUrl()
{
return baseUrl;
@@ -121,15 +108,12 @@ public class SolrIndexerAndSearcherFactory extends AbstractIndexerAndSearcher
@Override
public SearchService getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
{
//storeRef = tenantService.getName(storeRef);
SolrSearchService searchService = new SolrSearchService();
searchService.setDictionaryService(dictionaryService);
searchService.setNamespacePrefixResolver(namespacePrefixResolver);
searchService.setNodeService(nodeService);
searchService.setQueryLanguages(getQueryLanguages());
searchService.setQueryRegister(queryRegister);
searchService.setTenantService(tenantService);
return searchService;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -30,15 +30,14 @@ import javax.servlet.http.HttpServletResponse;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.httpclient.HttpClientFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParserException;
import org.alfresco.repo.search.impl.lucene.SolrJSONResultSet;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchParameters.FieldFacet;
import org.alfresco.service.cmr.search.SearchParameters.FieldFacetMethod;
@@ -76,6 +75,8 @@ public class SolrQueryHTTPClient
private NodeService nodeService;
private PermissionService permissionService;
private TenantService tenantService;
private Map<String, String> languageMappings;
@@ -121,6 +122,11 @@ public class SolrQueryHTTPClient
{
this.permissionService = permissionService;
}
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public void setLanguageMappings(Map<String, String> languageMappings)
{
@@ -136,11 +142,6 @@ public class SolrQueryHTTPClient
{
try
{
// Simple demo
// FieldFacet ff = new FieldFacet("@"+ContentModel.PROP_NAME);
// ff.setLimit(2);
// searchParameters.addFieldFacet(ff);
URLCodec encoder = new URLCodec();
StringBuilder url = new StringBuilder();
url.append(baseUrl);
@@ -216,25 +217,9 @@ public class SolrQueryHTTPClient
}
url.append(sortBuffer);
// Authorities go over in body
StringBuilder authQuery = new StringBuilder();
for (String authority : permissionService.getAuthorisations())
{
if (authQuery.length() > 0)
{
authQuery.append(" ");
}
authQuery.append("|AUTHORITY:\"").append(authority).append("\"");
}
// url.append("&fq=");
// encoder = new URLCodec();
// url.append(encoder.encode(authQuery.toString(), "UTF-8"));
url.append("&fq=").append(encoder.encode("{!afts}AUTHORITY_FILTER_FROM_JSON", "UTF-8"));
// facets would go on url?
url.append("&fq=").append(encoder.encode("{!afts}TENANT_FILTER_FROM_JSON", "UTF-8"));
if(searchParameters.getFieldFacets().size() > 0)
{
@@ -275,9 +260,20 @@ public class SolrQueryHTTPClient
JSONObject body = new JSONObject();
body.put("query", searchParameters.getQuery());
// body.put("defaultField", searchParameters.getDefaultFieldName());
body.put("filter", authQuery);
// Authorities go over as is - and tenant mangling and query building takes place on the SOLR side
JSONArray authorities = new JSONArray();
for (String authority : permissionService.getAuthorisations())
{
authorities.put(authority);
}
body.put("authorities", authorities);
JSONArray tenants = new JSONArray();
tenants.put(tenantService.getCurrentUserDomain());
body.put("tenants", tenants);
JSONArray locales = new JSONArray();
for (Locale currentLocale : searchParameters.getLocales())

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -34,7 +34,6 @@ import org.alfresco.repo.search.impl.NodeSearcher;
import org.alfresco.repo.search.impl.lucene.LuceneQueryLanguageSPI;
import org.alfresco.repo.search.impl.lucene.LuceneQueryParser;
import org.alfresco.repo.search.impl.lucene.QueryParameterisationException;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -46,8 +45,8 @@ import org.alfresco.service.cmr.search.QueryParameter;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.SearchParameters.Operator;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ISO9075;
@@ -58,11 +57,8 @@ import org.alfresco.util.SearchLanguageConversion;
*/
public class SolrSearchService implements SearchService
{
private NodeService nodeService;
private TenantService tenantService;
private NamespacePrefixResolver namespacePrefixResolver;
private DictionaryService dictionaryService;
@@ -81,16 +77,6 @@ public class SolrSearchService implements SearchService
this.nodeService = nodeService;
}
public TenantService getTenantService()
{
return tenantService;
}
public void setTenantService(TenantService tenantService)
{
this.tenantService = tenantService;
}
public NamespacePrefixResolver getNamespacePrefixResolver()
{
return namespacePrefixResolver;
@@ -150,8 +136,6 @@ public class SolrSearchService implements SearchService
@Override
public ResultSet query(StoreRef store, String language, String query, QueryParameterDefinition[] queryParameterDefinitions)
{
store = tenantService.getName(store);
SearchParameters sp = new SearchParameters();
sp.addStore(store);
sp.setLanguage(language);
@@ -164,10 +148,10 @@ public class SolrSearchService implements SearchService
}
}
sp.excludeDataInTheCurrentTransaction(true);
return query(sp);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#query(org.alfresco.service.cmr.repository.StoreRef,
@@ -337,10 +321,7 @@ public class SolrSearchService implements SearchService
{
throw new IllegalStateException("Only one store can be searched at present");
}
ArrayList<StoreRef> stores = searchParameters.getStores();
stores.set(0, tenantService.getName(searchParameters.getStores().get(0)));
String parameterisedQueryString;
if (searchParameters.getQueryParameterDefinitions().size() > 0)
{