mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
99486: Merged DEREK/BM-0004 (5.1.0.BM4) to HEAD-BUG-FIX (5.1/Cloud) 98804: Part 2: ACE-1021 SOLR 4 - Sharding/Replication/Cluster/Cloud - SOLR 4 - support multiple stores requested via search parameters - explicit federation over a specified set of stores and related SOLR 4 indexes git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@99545 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,9 +68,9 @@ public class SearcherComponent extends AbstractSearcherComponent
|
||||
|
||||
public ResultSet query(SearchParameters searchParameters)
|
||||
{
|
||||
if(searchParameters.getStores().size() != 1)
|
||||
if(searchParameters.getStores().size() == 0)
|
||||
{
|
||||
throw new IllegalStateException("Only one store can be searched at present");
|
||||
throw new IllegalStateException("At least one store must be defined to search");
|
||||
}
|
||||
StoreRef storeRef = searchParameters.getStores().get(0);
|
||||
SearchService searcher = indexerAndSearcherFactory.getSearcher(storeRef, !searchParameters.excludeDataInTheCurrentTransaction());
|
||||
|
@@ -156,6 +156,11 @@ public class DBQueryEngine implements QueryEngine
|
||||
Map<Set<String>, ResultSet> answer = new HashMap<Set<String>, ResultSet>();
|
||||
DBQuery dbQuery = (DBQuery)query;
|
||||
|
||||
if(options.getStores().size() > 1)
|
||||
{
|
||||
throw new QueryModelException("Multi-store queries are not supported");
|
||||
}
|
||||
|
||||
// MT
|
||||
StoreRef storeRef = options.getStores().get(0);
|
||||
storeRef = storeRef != null ? tenantService.getName(storeRef) : null;
|
||||
|
@@ -343,6 +343,29 @@ public class SolrQueryHTTPClient implements BeanFactoryAware
|
||||
url.append("?wt=").append(encoder.encode("json", "UTF-8"));
|
||||
url.append("&fl=").append(encoder.encode("DBID,score", "UTF-8"));
|
||||
|
||||
if(searchParameters.getStores().size() > 1)
|
||||
{
|
||||
boolean requiresSeparator = false;
|
||||
url.append("&shards=");
|
||||
for(StoreRef storeRef : searchParameters.getStores())
|
||||
{
|
||||
if(requiresSeparator)
|
||||
{
|
||||
url.append(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
requiresSeparator = true;
|
||||
}
|
||||
SolrStoreMapping shard = extractMapping(storeRef);
|
||||
HttpClient client = httpClients.get(storeRef);
|
||||
url.append(client.getHostConfiguration().getHost());
|
||||
url.append(':');
|
||||
url.append(client.getHostConfiguration().getPort());
|
||||
url.append(shard.getBaseUrl());
|
||||
}
|
||||
}
|
||||
|
||||
// Emulate old limiting behaviour and metadata
|
||||
final LimitBy limitBy;
|
||||
int maxResults = -1;
|
||||
|
@@ -317,9 +317,9 @@ public class SolrSearchService implements SearchService
|
||||
@Override
|
||||
public ResultSet query(SearchParameters searchParameters)
|
||||
{
|
||||
if (searchParameters.getStores().size() != 1)
|
||||
if(searchParameters.getStores().size() == 0)
|
||||
{
|
||||
throw new IllegalStateException("Only one store can be searched at present");
|
||||
throw new IllegalStateException("At least one store must be defined to search");
|
||||
}
|
||||
|
||||
String parameterisedQueryString;
|
||||
|
Reference in New Issue
Block a user