use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class DistribJoinFromCollectionTest method checkAbsentFromIndex.
private void checkAbsentFromIndex(String fromColl, String toColl, boolean isScoresTest) throws SolrServerException, IOException {
final String wrongName = fromColl + "WrongName";
final String joinQ = "{!join " + (anyScoreMode(isScoresTest)) + "from=join_s fromIndex=" + wrongName + " to=join_s}match_s:c";
final QueryRequest qr = new QueryRequest(params("collection", toColl, "q", joinQ, "fl", "id,get_s,score"));
try {
cluster.getSolrClient().request(qr);
} catch (HttpSolrClient.RemoteSolrException ex) {
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ex.code());
assertTrue(ex.getMessage().contains(wrongName));
}
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class DistributedVersionInfoTest method assertDocExists.
/**
* Query the real-time get handler for a specific doc by ID to verify it
* exists in the provided server, using distrib=false so it doesn't route to another replica.
*/
@SuppressWarnings("rawtypes")
protected Long assertDocExists(HttpSolrClient solr, String coll, String docId, Long expVers) throws Exception {
QueryRequest qr = new QueryRequest(params("qt", "/get", "id", docId, "distrib", "false", "fl", "id,_version_"));
NamedList rsp = solr.request(qr);
SolrDocument doc = (SolrDocument) rsp.get("doc");
String match = JSONTestUtil.matchObj("/id", doc, docId);
assertTrue("Doc with id=" + docId + " not found in " + solr.getBaseURL() + " due to: " + match + "; rsp=" + rsp, match == null);
Long vers = (Long) doc.getFirstValue("_version_");
assertNotNull(vers);
if (expVers != null)
assertEquals("expected version of doc " + docId + " to be " + expVers, expVers, vers);
return vers;
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method testZeroNumShards.
@Test
public void testZeroNumShards() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
params.set("name", "acollection");
params.set(REPLICATION_FACTOR, 10);
params.set("numShards", 0);
params.set("collection.configName", "conf");
final SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
expectThrows(Exception.class, () -> {
cluster.getSolrClient().request(request);
});
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class CollectionsAPIDistributedZkTest method testMissingNumShards.
@Test
public void testMissingNumShards() {
// No numShards should fail
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.CREATE.toString());
params.set("name", "acollection");
params.set(REPLICATION_FACTOR, 10);
params.set("collection.configName", "conf");
final SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
expectThrows(Exception.class, () -> {
cluster.getSolrClient().request(request);
});
}
use of org.apache.solr.client.solrj.request.QueryRequest in project lucene-solr by apache.
the class TestCollectionAPI method testCollectionCreationShardNameValidation.
private void testCollectionCreationShardNameValidation() throws Exception {
try (CloudSolrClient client = createCloudClient(null)) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionParams.CollectionAction.CREATE.toString());
params.set("name", "valid_collection_name");
params.set("router.name", "implicit");
params.set("numShards", "1");
params.set("shards", "invalid@name#with$weird%characters");
SolrRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
client.request(request);
fail();
} catch (RemoteSolrException e) {
final String errorMessage = e.getMessage();
assertTrue(errorMessage.contains("Invalid shard"));
assertTrue(errorMessage.contains("invalid@name#with$weird%characters"));
assertTrue(errorMessage.contains("shard names must consist entirely of"));
}
}
}
Aggregations