當前位置: 首頁>>代碼示例>>Java>>正文


Java ModifiableSolrParams.remove方法代碼示例

本文整理匯總了Java中org.apache.solr.common.params.ModifiableSolrParams.remove方法的典型用法代碼示例。如果您正苦於以下問題:Java ModifiableSolrParams.remove方法的具體用法?Java ModifiableSolrParams.remove怎麽用?Java ModifiableSolrParams.remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.solr.common.params.ModifiableSolrParams的用法示例。


在下文中一共展示了ModifiableSolrParams.remove方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getParams

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
@Override
public SolrParams getParams() {
  ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
  if (shardName == null || shardName.isEmpty()) {
    params.remove("shard");
    if (routeKey == null) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Either shard or routeKey must be provided");
    }
    params.add(ShardParams._ROUTE_, routeKey);
  }
  if (node != null) {
    params.add("node", node);
  }
  if (instanceDir != null)  {
    params.add("instanceDir", instanceDir);
  }
  if (dataDir != null)  {
    params.add("dataDir", dataDir);
  }
  return params;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:CollectionAdminRequest.java

示例2: redirectToQueryHandler

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
/**
 * redirects to query handler by using value of 'qt' parameter
 */
private static void redirectToQueryHandler(HttpServletRequest request, HttpServletResponse resp)
    throws IOException {
    ModifiableSolrParams solrQueryParameter = getSolrQueryParameter(request);
    String queryHandlerPath = solrQueryParameter.get(QUERY_HANDLER_PAR_NAME, QUERY_PATH);
    solrQueryParameter.remove(QUERY_HANDLER_PAR_NAME);
    Map<String, String[]> parameters = toMultiMap(solrQueryParameter);
    doRedirectToQueryHandler(resp, queryHandlerPath, parameters);
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:12,代碼來源:MCRSolrProxyServlet.java

示例3: getCommonParams

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
public ModifiableSolrParams getCommonParams() {
  ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
  params.remove( "name" );
  params.set( "collection", collection );
  params.set( "shard", shardName);
  params.set( "async", asyncId);
  return params;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:9,代碼來源:CollectionAdminRequest.java

示例4: query

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
/**
 * Returns the QueryResponse from {@link #queryServer}  
 */
protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exception {
  
  final ModifiableSolrParams params = new ModifiableSolrParams(p);

  // TODO: look into why passing true causes fails
  params.set("distrib", "false");
  final QueryResponse controlRsp = controlClient.query(params);
  validateControlData(controlRsp);

  params.remove("distrib");
  if (setDistribParams) setDistributedParams(params);

  QueryResponse rsp = queryServer(params);

  compareResponses(rsp, controlRsp);

  if (stress > 0) {
    log.info("starting stress...");
    Thread[] threads = new Thread[nThreads];
    for (int i = 0; i < threads.length; i++) {
      threads[i] = new Thread() {
        @Override
        public void run() {
          for (int j = 0; j < stress; j++) {
            int which = r.nextInt(clients.size());
            SolrServer client = clients.get(which);
            try {
              QueryResponse rsp = client.query(new ModifiableSolrParams(params));
              if (verifyStress) {
                compareResponses(rsp, controlRsp);
              }
            } catch (SolrServerException e) {
              throw new RuntimeException(e);
            }
          }
        }
      };
      threads[i].start();
    }

    for (Thread thread : threads) {
      thread.join();
    }
  }
  return rsp;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:50,代碼來源:BaseDistributedSearchTestCase.java

示例5: submit

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
@Override
public void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {
  // do this outside of the callable for thread safety reasons
  final List<String> urls = getURLs(shard);

  Callable<ShardResponse> task = new Callable<ShardResponse>() {
    @Override
    public ShardResponse call() throws Exception {

      ShardResponse srsp = new ShardResponse();
      if (sreq.nodeName != null) {
        srsp.setNodeName(sreq.nodeName);
      }
      srsp.setShardRequest(sreq);
      srsp.setShard(shard);
      SimpleSolrResponse ssr = new SimpleSolrResponse();
      srsp.setSolrResponse(ssr);
      long startTime = System.nanoTime();

      try {
        params.remove(CommonParams.WT); // use default (currently javabin)
        params.remove(CommonParams.VERSION);

        // SolrRequest req = new QueryRequest(SolrRequest.METHOD.POST, "/select");
        // use generic request to avoid extra processing of queries
        QueryRequest req = new QueryRequest(params);
        req.setMethod(SolrRequest.METHOD.POST);

        // no need to set the response parser as binary is the default
        // req.setResponseParser(new BinaryResponseParser());

        // if there are no shards available for a slice, urls.size()==0
        if (urls.size()==0) {
          // TODO: what's the right error code here? We should use the same thing when
          // all of the servers for a shard are down.
          throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "no servers hosting shard: " + shard);
        }

        if (urls.size() <= 1) {
          String url = urls.get(0);
          srsp.setShardAddress(url);
          SolrServer server = new HttpSolrServer(url, httpClient);
          try {
            ssr.nl = server.request(req);
          } finally {
            server.shutdown();
          }
        } else {
          LBHttpSolrServer.Rsp rsp = httpShardHandlerFactory.makeLoadBalancedRequest(req, urls);
          ssr.nl = rsp.getResponse();
          srsp.setShardAddress(rsp.getServer());
        }
      }
      catch( ConnectException cex ) {
        srsp.setException(cex); //????
      } catch (Exception th) {
        srsp.setException(th);
        if (th instanceof SolrException) {
          srsp.setResponseCode(((SolrException)th).code());
        } else {
          srsp.setResponseCode(-1);
        }
      }

      ssr.elapsedTime = TimeUnit.MILLISECONDS.convert(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);

      return srsp;
    }
  };

  pending.add( completionService.submit(task) );
}
 
開發者ID:europeana,項目名稱:search,代碼行數:73,代碼來源:HttpShardHandler.java

示例6: doEmptyFacetCounts

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
static void doEmptyFacetCounts(String field, String[] prefixes) throws Exception {
  SchemaField sf = h.getCore().getLatestSchema().getField(field);

  String response = JQ(req("q", "*:*"));
  Map rsp = (Map) ObjectBuilder.fromJSON(response);
  Long numFound  = (Long)(((Map)rsp.get("response")).get("numFound"));

  ModifiableSolrParams params = params("q","*:*", "rows","0", "facet","true", "facet.field","{!key=myalias}"+field);
  
  String[] methods = {null, "fc","enum","fcs"};
  if (sf.multiValued() || sf.getType().multiValuedFieldCache()) {
    methods = new String[]{null, "fc","enum"};
  }

  prefixes = prefixes==null ? new String[]{null} : prefixes;


  for (String method : methods) {
    if (method == null) {
      params.remove("facet.method");
    } else {
      params.set("facet.method", method);
    }
    for (String prefix : prefixes) {
      if (prefix == null) {
        params.remove("facet.prefix");
      } else {
        params.set("facet.prefix", prefix);
      }

      for (String missing : new String[] {null, "true"}) {
        if (missing == null) {
          params.remove("facet.missing");
        } else {
          params.set("facet.missing", missing);
        }
        
        String expected = missing==null ? "[]" : "[null," + numFound + "]";
        
        assertJQ(req(params),
            "/facet_counts/facet_fields/myalias==" + expected);
      }
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:46,代碼來源:SimpleFacetsTest.java

示例7: queryPartialResults

import org.apache.solr.common.params.ModifiableSolrParams; //導入方法依賴的package包/類
protected void queryPartialResults(final List<String> upShards,
                                   final List<SolrServer> upClients, 
                                   Object... q) throws Exception {
  
  final ModifiableSolrParams params = new ModifiableSolrParams();

  for (int i = 0; i < q.length; i += 2) {
    params.add(q[i].toString(), q[i + 1].toString());
  }
  // TODO: look into why passing true causes fails
  params.set("distrib", "false");
  final QueryResponse controlRsp = controlClient.query(params);
  // if time.allowed is specified then even a control response can return a partialResults header
  if (params.get(CommonParams.TIME_ALLOWED) == null)  {
    validateControlData(controlRsp);
  }

  params.remove("distrib");
  setDistributedParams(params);

  QueryResponse rsp = queryRandomUpServer(params,upClients);

  comparePartialResponses(rsp, controlRsp, upShards);

  if (stress > 0) {
    log.info("starting stress...");
    Thread[] threads = new Thread[nThreads];
    for (int i = 0; i < threads.length; i++) {
      threads[i] = new Thread() {
        @Override
        public void run() {
          for (int j = 0; j < stress; j++) {
            int which = r.nextInt(upClients.size());
            SolrServer client = upClients.get(which);
            try {
              QueryResponse rsp = client.query(new ModifiableSolrParams(params));
              if (verifyStress) {
                comparePartialResponses(rsp, controlRsp, upShards);
              }
            } catch (SolrServerException e) {
              throw new RuntimeException(e);
            }
          }
        }
      };
      threads[i].start();
    }

    for (Thread thread : threads) {
      thread.join();
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:54,代碼來源:TestDistributedSearch.java


注:本文中的org.apache.solr.common.params.ModifiableSolrParams.remove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。