use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class TestTolerantUpdateProcessorRandomCloud method allDocs.
/** uses a Cursor to iterate over every doc in the index, recording the 'id_i' value in a BitSet */
private static final BitSet allDocs(final SolrClient c, final int maxDocIdExpected) throws Exception {
BitSet docs = new BitSet(maxDocIdExpected + 1);
String cursorMark = CURSOR_MARK_START;
int docsOnThisPage = Integer.MAX_VALUE;
while (0 < docsOnThisPage) {
final SolrParams p = params("q", "*:*", "rows", "100", // note: not numeric, but we don't actual care about the order
"sort", "id asc", CURSOR_MARK_PARAM, cursorMark);
QueryResponse rsp = c.query(p);
cursorMark = rsp.getNextCursorMark();
docsOnThisPage = 0;
for (SolrDocument doc : rsp.getResults()) {
docsOnThisPage++;
int id_i = ((Integer) doc.get("id_i")).intValue();
assertTrue("found id_i bigger then expected " + maxDocIdExpected + ": " + id_i, id_i <= maxDocIdExpected);
docs.set(id_i);
}
cursorMark = rsp.getNextCursorMark();
}
return docs;
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class TriLevelCompositeIdRoutingTest method doQueryGetUniqueIdKeys.
Set<String> doQueryGetUniqueIdKeys(String... queryParams) throws Exception {
QueryResponse rsp = cloudClient.query(params(queryParams));
Set<String> obtainedIdKeys = new HashSet<>();
for (SolrDocument doc : rsp.getResults()) {
obtainedIdKeys.add(getKey((String) doc.get("id")));
}
return obtainedIdKeys;
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class TestReplicationHandler method getSlaveDetails.
private String getSlaveDetails(String keyName) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CommonParams.QT, "/replication");
params.set("command", "details");
QueryResponse response = slaveClient.query(params);
System.out.println("SHALIN: " + response.getResponse());
// details/slave/timesIndexReplicated
NamedList<Object> details = (NamedList<Object>) response.getResponse().get("details");
NamedList<Object> slave = (NamedList<Object>) details.get("slave");
Object o = slave.get(keyName);
return o != null ? o.toString() : null;
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class TestReplicationHandler method query.
NamedList query(String query, SolrClient s) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("q", query);
params.add("sort", "id desc");
QueryResponse qres = s.query(params);
return qres.getResponse();
}
use of org.apache.solr.client.solrj.response.QueryResponse in project lucene-solr by apache.
the class MergeStrategyTest method test.
@Test
@ShardsFixed(num = 3)
public void test() throws Exception {
del("*:*");
index_specific(0, "id", "1", "sort_i", "5");
index_specific(0, "id", "2", "sort_i", "50");
index_specific(1, "id", "5", "sort_i", "4");
index_specific(1, "id", "6", "sort_i", "10");
index_specific(0, "id", "7", "sort_i", "1");
index_specific(1, "id", "8", "sort_i", "2");
index_specific(2, "id", "9", "sort_i", "1000");
index_specific(2, "id", "10", "sort_i", "1500");
index_specific(2, "id", "11", "sort_i", "1300");
index_specific(1, "id", "12", "sort_i", "15");
index_specific(1, "id", "13", "sort_i", "16");
commit();
handle.put("explain", SKIPVAL);
handle.put("timestamp", SKIPVAL);
handle.put("score", SKIPVAL);
handle.put("wt", SKIP);
handle.put("distrib", SKIP);
handle.put("shards.qt", SKIP);
handle.put("shards", SKIP);
handle.put("q", SKIP);
handle.put("maxScore", SKIPVAL);
handle.put("_version_", SKIP);
//Test mergeStrategy that uses score
query("rq", "{!rank}", "q", "*:*", "rows", "12", "sort", "sort_i asc", "fl", "*,score");
//Test without mergeStrategy
query("q", "*:*", "rows", "12", "sort", "sort_i asc");
//Test mergeStrategy1 that uses a sort field.
query("rq", "{!rank mergeStrategy=1}", "q", "*:*", "rows", "12", "sort", "sort_i asc");
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("q", "*:*");
params.add("rows", "12");
params.add("rq", "{!rank}");
params.add("sort", "sort_i asc");
params.add("fl", "*,score");
setDistributedParams(params);
QueryResponse rsp = queryServer(params);
assertOrder(rsp, "10", "11", "9", "2", "13", "12", "6", "1", "5", "8", "7");
params = new ModifiableSolrParams();
params.add("q", "*:*");
params.add("rows", "12");
params.add("sort", "sort_i asc");
params.add("fl", "*,score");
setDistributedParams(params);
rsp = queryServer(params);
assertOrder(rsp, "7", "8", "5", "1", "6", "12", "13", "2", "9", "11", "10");
MergeStrategy m1 = new MergeStrategy() {
@Override
public void merge(ResponseBuilder rb, ShardRequest sreq) {
}
public boolean mergesIds() {
return true;
}
public boolean handlesMergeFields() {
return false;
}
public void handleMergeFields(ResponseBuilder rb, SolrIndexSearcher searcher) {
}
@Override
public int getCost() {
return 1;
}
};
MergeStrategy m2 = new MergeStrategy() {
@Override
public void merge(ResponseBuilder rb, ShardRequest sreq) {
}
public boolean mergesIds() {
return true;
}
public boolean handlesMergeFields() {
return false;
}
public void handleMergeFields(ResponseBuilder rb, SolrIndexSearcher searcher) {
}
@Override
public int getCost() {
return 100;
}
};
MergeStrategy m3 = new MergeStrategy() {
@Override
public void merge(ResponseBuilder rb, ShardRequest sreq) {
}
public boolean mergesIds() {
return false;
}
public boolean handlesMergeFields() {
return false;
}
public void handleMergeFields(ResponseBuilder rb, SolrIndexSearcher searcher) {
}
@Override
public int getCost() {
return 50;
}
};
MergeStrategy[] merges = { m1, m2, m3 };
Arrays.sort(merges, MergeStrategy.MERGE_COMP);
assert (merges[0].getCost() == 1);
assert (merges[1].getCost() == 50);
assert (merges[2].getCost() == 100);
}
Aggregations