本文整理汇总了Java中org.apache.solr.client.solrj.request.QueryRequest.setPath方法的典型用法代码示例。如果您正苦于以下问题:Java QueryRequest.setPath方法的具体用法?Java QueryRequest.setPath怎么用?Java QueryRequest.setPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.solr.client.solrj.request.QueryRequest
的用法示例。
在下文中一共展示了QueryRequest.setPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAlias
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private void createAlias(String alias, String collections)
throws SolrServerException, IOException {
SolrServer server = createNewSolrServer("",
getBaseUrl((HttpSolrServer) clients.get(0)));
if (random().nextBoolean()) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("collections", collections);
params.set("name", alias);
params.set("action", CollectionAction.CREATEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
server.request(request);
} else {
CollectionAdminRequest.CreateAlias.createAlias(alias, collections, server);
}
server.shutdown();
}
示例2: deleteAlias
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private void deleteAlias(String alias) throws SolrServerException,
IOException {
SolrServer server = createNewSolrServer("",
getBaseUrl((HttpSolrServer) clients.get(0)));
if (random().nextBoolean()) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("name", alias);
params.set("action", CollectionAction.DELETEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
server.request(request);
} else {
CollectionAdminRequest.deleteAlias(alias,server);
}
server.shutdown();
}
示例3: testTagStreaming
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
@Test
public void testTagStreaming() throws IOException, SolrServerException {
ModifiableSolrParams params = params();
String input = "foo boston bar";//just one tag;
QueryRequest req = new SolrTaggerRequest(params, input);
req.setPath("/tag");
final AtomicReference<SolrDocument> refDoc = new AtomicReference<>();
req.setStreamingResponseCallback(new StreamingResponseCallback() {
@Override
public void streamSolrDocument(SolrDocument doc) {
refDoc.set(doc);
}
@Override
public void streamDocListInfo(long numFound, long start, Float maxScore) {
}
});
QueryResponse rsp = req.process(solrServer);
assertNotNull(rsp.getResponse().get("tags"));
assertNotNull(refDoc.get());
assertEquals("Boston", ((Field)refDoc.get().getFieldValue("name")).stringValue());
}
示例4: createCollection
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
protected NamedList<Object> createCollection(CloudSolrClient server, String name, int numShards,
int replicationFactor, String configName) throws Exception {
ModifiableSolrParams modParams = new ModifiableSolrParams();
modParams.set(CoreAdminParams.ACTION, CollectionAction.CREATE.name());
modParams.set("name", name);
modParams.set("numShards", numShards);
modParams.set("replicationFactor", replicationFactor);
modParams.set("collection.configName", configName);
QueryRequest request = new QueryRequest(modParams);
request.setPath("/admin/collections");
return server.request(request);
}
示例5: createCollection
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
protected static void createCollection(String collectionName, int numShards, int replicationFactor, String
confName, File confDir) throws Exception {
if (confDir != null) {
assertTrue("Specified Solr config directory '" +
confDir.getAbsolutePath() + "' not found!", confDir.isDirectory());
// upload the test configs
SolrZkClient zkClient = cloudSolrClient.getZkStateReader().getZkClient();
ZkConfigManager zkConfigManager =
new ZkConfigManager(zkClient);
zkConfigManager.uploadConfigDir(confDir.toPath(), confName);
}
ModifiableSolrParams modParams = new ModifiableSolrParams();
modParams.set(CoreAdminParams.ACTION, CollectionParams.CollectionAction.CREATE.name());
modParams.set("name", collectionName);
modParams.set("numShards", numShards);
modParams.set("replicationFactor", replicationFactor);
int liveNodes = cloudSolrClient.getZkStateReader().getClusterState().getLiveNodes().size();
int maxShardsPerNode = (int) Math.ceil(((double) numShards * replicationFactor) / liveNodes);
modParams.set("maxShardsPerNode", maxShardsPerNode);
modParams.set("collection.configName", confName);
QueryRequest request = new QueryRequest(modParams);
request.setPath("/admin/collections");
cloudSolrClient.request(request);
ensureAllReplicasAreActive(collectionName, numShards, replicationFactor, 20);
}
示例6: createAlias
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private NamedList<Object> createAlias(String alias, String collections) throws SolrServerException, IOException {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("collections", collections);
params.set("name", alias);
params.set("action", CollectionAction.CREATEALIAS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
return cloudClient.request(request);
}
示例7: test404ViaHttp
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public void test404ViaHttp() throws SolrServerException {
SolrServer server = getSolrServer();
QueryRequest request = new QueryRequest(params("file",
"does-not-exist-404.txt"));
request.setPath("/admin/file");
try {
QueryResponse resp = request.process(server);
fail("didn't get 404 exception");
} catch (SolrException e) {
assertEquals(404, e.code());
}
}
示例8: testDirList
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public void testDirList() throws SolrServerException {
SolrServer server = getSolrServer();
//assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
QueryRequest request = new QueryRequest();
request.setPath("/admin/file");
QueryResponse resp = request.process(server);
assertEquals(0,resp.getStatus());
assertTrue(((NamedList) resp.getResponse().get("files")).size() > 0);//some files
}
示例9: testGetRawFile
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public void testGetRawFile() throws SolrServerException, IOException {
SolrServer server = getSolrServer();
//assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
QueryRequest request = new QueryRequest(params("file","schema.xml"));
request.setPath("/admin/file");
final AtomicBoolean readFile = new AtomicBoolean();
request.setResponseParser(new ResponseParser() {
@Override
public String getWriterType() {
return "mock";//unfortunately this gets put onto params wt=mock but it apparently has no effect
}
@Override
public NamedList<Object> processResponse(InputStream body, String encoding) {
try {
if (body.read() >= 0)
readFile.set(true);
} catch (IOException e) {
throw new RuntimeException(e);
}
return null;
}
@Override
public NamedList<Object> processResponse(Reader reader) {
throw new UnsupportedOperationException("TODO unimplemented");//TODO
}
});
server.request( request );//runs request
//request.process(server); but we don't have a NamedList response
assertTrue(readFile.get());
}
示例10: watchCoreStartAt
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
/**
* Polls the SolrCore stats using the specified client until the "startTime"
* time for collection is after the specified "min". Will loop for
* at most "timeout" milliseconds before throwing an assertion failure.
*
* @param client The SolrServer to poll
* @param timeout the max milliseconds to continue polling for
* @param min the startTime value must exceed this value before the method will return, if null this method will return the first startTime value encountered.
* @return the startTime value of collection
*/
private Date watchCoreStartAt(SolrServer client, final long timeout,
final Date min) throws InterruptedException, IOException, SolrServerException {
final long sleepInterval = 200;
long timeSlept = 0;
SolrParams p = params("action","status", "core", "collection1");
while (timeSlept < timeout) {
QueryRequest req = new QueryRequest(p);
req.setPath("/admin/cores");
try {
NamedList data = client.request(req);
for (String k : new String[] {"status","collection1"}) {
Object o = data.get(k);
assertNotNull("core status rsp missing key: " + k, o);
data = (NamedList) o;
}
Date startTime = (Date) data.get("startTime");
assertNotNull("core has null startTime", startTime);
if (null == min || startTime.after(min)) {
return startTime;
}
} catch (SolrException e) {
// workarround for SOLR-4668
if (500 != e.code()) {
throw e;
} // else server possibly from the core reload in progress...
}
timeSlept += sleepInterval;
Thread.sleep(sleepInterval);
}
fail("timed out waiting for collection1 startAt time to exceed: " + min);
return min; // compilation neccessity
}
示例11: createCollection
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
protected NamedList<Object> createCollection(CloudSolrServer server, String name, int numShards,
int replicationFactor, String configName) throws Exception {
ModifiableSolrParams modParams = new ModifiableSolrParams();
modParams.set(CoreAdminParams.ACTION, CollectionAction.CREATE.name());
modParams.set("name", name);
modParams.set("numShards", numShards);
modParams.set("replicationFactor", replicationFactor);
modParams.set("collection.configName", configName);
QueryRequest request = new QueryRequest(modParams);
request.setPath("/admin/collections");
return server.request(request);
}
示例12: deleteCollectionRemovesStaleZkCollectionsNode
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
// we can use this client because we just want base url
final String baseUrl = getBaseUrl((HttpSolrServer) clients.get(0));
String collectionName = "out_of_sync_collection";
List<Integer> numShardsNumReplicaList = new ArrayList<>();
numShardsNumReplicaList.add(2);
numShardsNumReplicaList.add(1);
cloudClient.getZkStateReader().getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true);
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action", CollectionAction.DELETE.toString());
params.set("name", collectionName);
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/collections");
try {
NamedList<Object> resp = createNewSolrServer("", baseUrl)
.request(request);
fail("Expected to fail, because collection is not in clusterstate");
} catch (RemoteSolrException e) {
}
checkForMissingCollection(collectionName);
assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
}
示例13: doTest
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
@Override
public void doTest() throws Exception {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.STATUS.toString());
QueryRequest request = new QueryRequest(params);
request.setPath("/admin/cores");
int which = r.nextInt(clients.size());
HttpSolrServer client = (HttpSolrServer)clients.get(which);
String previousBaseURL = client.getBaseURL();
// Strip /collection1 step from baseURL - requests fail otherwise
client.setBaseURL(previousBaseURL.substring(0, previousBaseURL.lastIndexOf("/")));
NamedList namedListResponse = client.request(request);
client.setBaseURL(previousBaseURL); // Restore baseURL
NamedList status = (NamedList)namedListResponse.get("status");
NamedList collectionStatus = (NamedList)status.get("collection1");
String collectionSchema = (String)collectionStatus.get(CoreAdminParams.SCHEMA);
// Make sure the upgrade to managed schema happened
assertEquals("Schema resource name differs from expected name", "managed-schema", collectionSchema);
SolrZkClient zkClient = new SolrZkClient(zkServer.getZkHost(), 30000);
try {
// Make sure "DO NOT EDIT" is in the content of the managed schema
String fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/managed-schema");
assertTrue("Managed schema is missing", fileContent.contains("DO NOT EDIT"));
// Make sure the original non-managed schema is no longer in ZooKeeper
assertFileNotInZooKeeper(zkClient, "/solr/configs/conf1", "schema.xml");
// Make sure the renamed non-managed schema is present in ZooKeeper
fileContent = getFileContentFromZooKeeper(zkClient, "/solr/configs/conf1/schema.xml.bak");
assertTrue("schema file doesn't contain '<schema'", fileContent.contains("<schema"));
} finally {
if (zkClient != null) {
zkClient.close();
}
}
}
示例14: getCreateCollectionsRequest
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public QueryRequest getCreateCollectionsRequest(String name, int numShards, int replicationFactor) {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.CREATE.name());
params.set(SolrConstants.REQUEST_NAME, name);
params.set(SolrConstants.REQUEST_NUM_SHARDS, numShards);
params.set(SolrConstants.REQUEST_REPLICATION_FACTOR, replicationFactor);
params.set(SolrConstants.REQUEST_COLLECTION_CONFIG_NAME, name);
QueryRequest request = new QueryRequest(params);
request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH);
return request;
}
示例15: getListCollectionsRequest
import org.apache.solr.client.solrj.request.QueryRequest; //导入方法依赖的package包/类
public QueryRequest getListCollectionsRequest() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.LIST.name());
QueryRequest request = new QueryRequest(params);
request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH);
return request;
}