SEARCH-561: Sharding restricts the number of results / allowed page sizes

This commit is contained in:
Joel
2017-12-11 10:45:10 -05:00
parent 56f6645d08
commit e415563d9a
4 changed files with 121 additions and 17 deletions
@@ -36,14 +36,7 @@ public class AlfrescoHttpShardHandler extends HttpShardHandler {
*/
protected QueryRequest makeQueryRequest(final ShardRequest sreq, ModifiableSolrParams params, String shard)
{
String json = params.get(AbstractQParser.ALFRESCO_JSON);
params.remove(AbstractQParser.ALFRESCO_JSON);
AlfrescoQueryRequest req = new AlfrescoQueryRequest(params, SolrRequest.METHOD.POST);
if(json != null)
{
req.setContentStream(new ContentStreamBase.StringStream(json));
}
return req;
}
}
@@ -228,8 +228,7 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
}
Iterable<ContentStream> streams = req.getContentStreams();
JSONObject json = (JSONObject) req.getContext().get(
AbstractQParser.ALFRESCO_JSON);
JSONObject json = (JSONObject) req.getContext().get(AbstractQParser.ALFRESCO_JSON);
if (json == null) {
if (streams != null) {
@@ -254,6 +253,9 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
throw new AlfrescoRuntimeException(
"IO Error parsing query parameters", e);
}
} else if(req.getParams().get(AbstractQParser.ALFRESCO_JSON) != null) {
//json is in the params.
req.getContext().put(AbstractQParser.ALFRESCO_JSON, new JSONObject(req.getParams().get(AbstractQParser.ALFRESCO_JSON)));
}
}
}
@@ -452,13 +454,10 @@ public class AlfrescoSearchHandler extends RequestHandlerBase implements
// what
// was
// asked
if (req.getContext().get(
AbstractQParser.ALFRESCO_JSON) != null) {
params.set(
AbstractQParser.ALFRESCO_JSON,
((JSONObject) req.getContext().get(
AbstractQParser.ALFRESCO_JSON))
.toString());
if (req.getContext().get(AbstractQParser.ALFRESCO_JSON) != null) {
//This will add the Alfresco JSON as a parameter, overwriting the parameter if it already exists.
params.set(AbstractQParser.ALFRESCO_JSON,
req.getContext().get(AbstractQParser.ALFRESCO_JSON).toString());
}
if (rb.requestInfo != null) {
// we could try and detect when this is needed,
@@ -777,6 +777,7 @@ public class AlfrescoSolrUtils
public static class TestActChanges {
private AclChangeSet aclChangeSet;
private Acl acl;
private Acl acl2;
public AclChangeSet getChangeSet() {
return aclChangeSet;
@@ -785,12 +786,16 @@ public class AlfrescoSolrUtils
public Acl getFirstAcl() {
return acl;
}
public Acl getSecondAcl() {
return acl2;
}
public TestActChanges createBasicTestData() {
aclChangeSet = getAclChangeSet(1);
acl = getAcl(aclChangeSet);
Acl acl2 = getAcl(aclChangeSet);
acl2 = getAcl(aclChangeSet);
AclReaders aclReaders = getAclReaders(aclChangeSet, acl, list("joel"), list("phil"), null);
AclReaders aclReaders2 = getAclReaders(aclChangeSet, acl2, list("jim"), list("phil"), null);
@@ -0,0 +1,107 @@
/*
* Copyright (C) 2005-2014 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.solr.tracker;
import org.alfresco.solr.AbstractAlfrescoDistributedTest;
import org.alfresco.repo.search.adaptor.lucene.QueryConstants;
import org.alfresco.solr.client.*;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.LegacyNumericRangeQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.junit.Rule;
import org.junit.Test;
import static org.alfresco.solr.AlfrescoSolrUtils.*;
import static org.alfresco.solr.AlfrescoSolrUtils.getAclReaders;
import static org.alfresco.solr.AlfrescoSolrUtils.list;
import java.util.List;
import java.util.ArrayList;
/**
* @author Joel
*/
@SolrTestCaseJ4.SuppressSSL
@LuceneTestCase.SuppressCodecs({"Appending","Lucene3x","Lucene40","Lucene41","Lucene42","Lucene43", "Lucene44", "Lucene45","Lucene46","Lucene47","Lucene48","Lucene49"})
public class DistributedAlfrescoSolrJsonTest extends AbstractAlfrescoDistributedTest
{
@Rule
public JettyServerRule jetty = new JettyServerRule(2, this);
@Test
public void testTracker() throws Exception
{
TestActChanges testActChanges = new TestActChanges().createBasicTestData();
AclChangeSet aclChangeSet = testActChanges.getChangeSet();
Acl acl1 = testActChanges.getFirstAcl();
Acl acl2 = testActChanges.getSecondAcl();
BooleanQuery.Builder builder = new BooleanQuery.Builder();
builder.add(new BooleanClause(new TermQuery(new Term(QueryConstants.FIELD_SOLR4_ID, "TRACKER!STATE!ACLTX")), BooleanClause.Occur.MUST));
builder.add(new BooleanClause(LegacyNumericRangeQuery.newLongRange(QueryConstants.FIELD_S_ACLTXID, aclChangeSet.getId(), aclChangeSet.getId() + 1, true, false), BooleanClause.Occur.MUST));
BooleanQuery waitForQuery = builder.build();
waitForDocCountAllCores(waitForQuery, 1, 80000);
putHandleDefaults();
//Load 1000 nodes
int numNodes = 1000;
List<Node> nodes = new ArrayList();
List<NodeMetaData> nodeMetaDatas = new ArrayList();
Transaction bigTxn = getTransaction(0, numNodes);
for(int i=0; i<500; i++) {
Node node = getNode(bigTxn, acl1, Node.SolrApiNodeStatus.UPDATED);
nodes.add(node);
NodeMetaData nodeMetaData = getNodeMetaData(node, bigTxn, acl1, "mike", null, false);
nodeMetaDatas.add(nodeMetaData);
}
for(int i=0; i<500; i++) {
Node node = getNode(bigTxn, acl2, Node.SolrApiNodeStatus.UPDATED);
nodes.add(node);
NodeMetaData nodeMetaData = getNodeMetaData(node, bigTxn, acl2, "steve", null, false);
nodeMetaDatas.add(nodeMetaData);
}
indexTransaction(bigTxn, nodes, nodeMetaDatas);
waitForDocCount(new TermQuery(new Term("content@s___t@{http://www.alfresco.org/model/content/1.0}content", "world")), numNodes, 100000);
QueryResponse queryResponse = query(getDefaultTestClient(),
true,
"{\"authorities\": [ \"jim\", \"joel\" ], \"tenants\": [ \"\" ], \"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}]}",
params("q", "t1:world", "qt", "/afts", "fq", "{!afts}AUTHORITY_FILTER_FROM_JSON", "shards.qt", "/afts", "start", "0", "rows", "1000", "sort", "id asc"));
assertEquals(queryResponse.getResults().getNumFound(), 1000);
queryResponse = query(getDefaultTestClient(),
true,
"{\"authorities\": [ \"jim\" ], \"tenants\": [ \"\" ], \"locales\":[\"en\"], \"templates\": [{\"name\":\"t1\", \"template\":\"%cm:content\"}]}",
params("q", "t1:world", "qt", "/afts", "fq", "{!afts}AUTHORITY_FILTER_FROM_JSON", "shards.qt", "/afts", "start", "0", "rows", "100", "sort", "id asc"));
assertEquals(queryResponse.getResults().getNumFound(), 500);
}
}