当前位置: 首页>>代码示例>>Java>>正文


Java ModifiableSolrParams.set方法代码示例

本文整理汇总了Java中org.apache.solr.common.params.ModifiableSolrParams.set方法的典型用法代码示例。如果您正苦于以下问题:Java ModifiableSolrParams.set方法的具体用法?Java ModifiableSolrParams.set怎么用?Java ModifiableSolrParams.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.common.params.ModifiableSolrParams的用法示例。


在下文中一共展示了ModifiableSolrParams.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMapFieldName

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Test
public void testMapFieldName() throws Exception {
  ModifiableSolrParams parameters = new ModifiableSolrParams();
  parameters.add("langid.fl", "name");
  parameters.add("langid.map.lcmap", "jp:s zh:cjk ko:cjk");
  parameters.set("langid.enforceSchema", "false");
  liProcessor = createLangIdProcessor(parameters);
  
  assertEquals("test_no", liProcessor.getMappedField("test", "no"));
  assertEquals("test_en", liProcessor.getMappedField("test", "en"));
  assertEquals("test_s", liProcessor.getMappedField("test", "jp"));
  assertEquals("test_cjk", liProcessor.getMappedField("test", "zh"));
  assertEquals("test_cjk", liProcessor.getMappedField("test", "ko"));

  // Test that enforceSchema correctly catches illegal field and returns null
  parameters.set("langid.enforceSchema", "true");
  liProcessor = createLangIdProcessor(parameters);
  assertEquals(null, liProcessor.getMappedField("inputfield", "sv"));

  // Prove support for other mapping regex, still with enforceSchema=true
  parameters.add("langid.map.pattern", "text_(.*?)_field");
  parameters.add("langid.map.replace", "$1_{lang}_s");
  liProcessor = createLangIdProcessor(parameters);
  assertEquals("title_no_s", liProcessor.getMappedField("text_title_field", "no"));
  assertEquals("body_sv_s", liProcessor.getMappedField("text_body_field", "sv"));
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:LanguageIdentifierUpdateProcessorFactoryTestCase.java

示例2: filter

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
public boolean filter(MCRSet set) {
    if (!filterEmptySets()) {
        return false;
    }
    SolrClient solrClient = MCRSolrClientFactory.getSolrClient();
    ModifiableSolrParams p = new ModifiableSolrParams();
    String value = set.getSpec();
    p.set(CommonParams.Q, MCROAIUtils.getDefaultSetQuery(value, getConfigPrefix()));
    String restriction = MCROAIUtils.getDefaultRestriction(getConfigPrefix());
    if (restriction != null) {
        p.set(CommonParams.FQ, restriction);
    }
    p.set(CommonParams.ROWS, 1);
    p.set(CommonParams.FL, "id");
    try {
        QueryResponse response = solrClient.query(p);
        return response.getResults().isEmpty();
    } catch (Exception exc) {
        LOGGER.error("Unable to get results of solr server", exc);
        return true;
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:24,代码来源:MCROAIClassificationToSetHandler.java

示例3: filter

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@GET
@Path("filter/{text}")
@Produces(MediaType.APPLICATION_JSON)
public Response filter(@PathParam("text") String text) {
    SolrClient solrClient = MCRSolrClassificationUtil.getCore().getClient();
    ModifiableSolrParams p = new ModifiableSolrParams();
    p.set("q", "*" + text + "*");
    p.set("fl", "id,ancestors");

    JsonArray docList = new JsonArray();
    MCRSolrSearchUtils.stream(solrClient, p).flatMap(document -> {
        List<String> ids = new ArrayList<>();
        ids.add(document.getFirstValue("id").toString());
        Collection<Object> fieldValues = document.getFieldValues("ancestors");
        if (fieldValues != null) {
            for (Object anc : fieldValues) {
                ids.add(anc.toString());
            }
        }
        return ids.stream();
    }).distinct().map(JsonPrimitive::new).forEach(docList::add);
    return Response.ok().entity(docList.toString()).build();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:24,代码来源:MCRClassificationEditorResource.java

示例4: forEachRemaining

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
public void forEachRemaining(Consumer<? super SolrDocument> action) {
    if (action == null)
        throw new NullPointerException();
    ModifiableSolrParams p = new ModifiableSolrParams(params);
    p.set("rows", (int) rows);
    long start = this.start, size = estimateSize(), fetched = 0;
    while (fetched < size) {
        p.set("start", (int) (start + fetched));
        response = query(p);
        SolrDocumentList results = response.getResults();
        for (SolrDocument doc : results) {
            action.accept(doc);
        }
        fetched += results.size();
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:18,代码来源:MCRSolrSearchUtils.java

示例5: get

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
public T get(K key, String[] fields) {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CommonParams.QT, "/get");
  params.set(CommonParams.FL, toDelimitedString(fields, ","));
  params.set("id", key.toString());
  try {
    QueryResponse rsp = server.query(params);
    Object o = rsp.getResponse().get("doc");
    if (o == null) {
      return null;
    }
    return newInstance((SolrDocument) o, fields);
  } catch (Exception e) {
    LOG.error(e.getMessage(), e);
  }
  return null;
}
 
开发者ID:jianglibo,项目名称:gora-boot,代码行数:19,代码来源:SolrStore.java

示例6: handleSuggestionHitsRequest

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
public long handleSuggestionHitsRequest(ReSearcherRequestContext ctx, String query, Set<String> componentNames) throws Exception {
  ModifiableSolrParams params = new ModifiableSolrParams(ctx.getParams());
  params.set(CommonParams.ROWS, "0");
  for(String componentName : componentNames) {
    params.set(componentName, "false");
  }
  params.set(CommonParams.Q, query);

  SolrQueryRequest req = new SolrQueryRequestBase(ctx.getCore(), params) {};
  SolrQueryResponse rsp = new SolrQueryResponse();
  ResponseBuilder rb = new ResponseBuilder(req, rsp, ctx.getQueryOnlyComponents());
  
  try {
    handleSuggestionRequest(ctx, rb, ctx.getQueryOnlyComponents(), true);
  } finally {
    req.close();
  }
  
  return ReSearcherUtils.extractOriginalQueryHits(rb);
}
 
开发者ID:sematext,项目名称:solr-researcher,代码行数:21,代码来源:ReSearcherHandler.java

示例7: createCollection

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor, 
    String configName, String createNodeSet, String asyncId, Map<String, String> collectionProperties) throws SolrServerException, IOException {
  final ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CoreAdminParams.ACTION, CollectionAction.CREATE.name());
  params.set(CoreAdminParams.NAME, name);
  params.set("numShards", numShards);
  params.set("replicationFactor", replicationFactor);
  params.set("collection.configName", configName);
  if (null != createNodeSet) {
    params.set(OverseerCollectionMessageHandler.CREATE_NODE_SET, createNodeSet);
  }
  if (null != asyncId) {
    params.set(CommonAdminParams.ASYNC, asyncId);
  }
  if(collectionProperties != null) {
    for(Map.Entry<String, String> property : collectionProperties.entrySet()){
      params.set(CoreAdminParams.PROPERTY_PREFIX + property.getKey(), property.getValue());
    }
  }
  
  return makeCollectionsRequest(params);
}
 
开发者ID:BorisNaguet,项目名称:solr-maven-plugin,代码行数:23,代码来源:MiniSolrCloudCluster.java

示例8: invokeOverseerOp

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
private void invokeOverseerOp(String electionNode, String op) {
  ModifiableSolrParams params = new ModifiableSolrParams();
  ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
  params.set(CoreAdminParams.ACTION, CoreAdminAction.OVERSEEROP.toString());
  params.set("op", op);
  params.set("qt", adminPath);
  params.set("electionNode", electionNode);
  ShardRequest sreq = new ShardRequest();
  sreq.purpose = 1;
  String replica = zkStateReader.getBaseUrlForNodeName(LeaderElector.getNodeName(electionNode));
  sreq.shards = new String[]{replica};
  sreq.actualShards = sreq.shards;
  sreq.params = params;
  shardHandler.submit(sreq, replica, sreq.params);
  shardHandler.takeCompletedOrError();
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:OverseerCollectionProcessor.java

示例9: getNumRequests

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
private Long getNumRequests(HttpSolrServer solrServer) throws
    SolrServerException, IOException {
  HttpSolrServer server = new HttpSolrServer(solrServer.getBaseURL());
  server.setConnectionTimeout(15000);
  server.setSoTimeout(60000);
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set("qt", "/admin/mbeans");
  params.set("stats", "true");
  params.set("key", "org.apache.solr.handler.StandardRequestHandler");
  params.set("cat", "QUERYHANDLER");
  // use generic request to avoid extra processing of queries
  QueryRequest req = new QueryRequest(params);
  NamedList<Object> resp = server.request(req);
  NamedList mbeans = (NamedList) resp.get("solr-mbeans");
  NamedList queryHandler = (NamedList) mbeans.get("QUERYHANDLER");
  NamedList select = (NamedList) queryHandler.get("org.apache.solr.handler.StandardRequestHandler");
  NamedList stats = (NamedList) select.get("stats");
  return (Long) stats.get("requests");
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:CloudSolrServerTest.java

示例10: setUpBeforeClass

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  System.setProperty("enable.update.log", "false"); // schema12 doesn't support _version_
  initCore("solrconfig.xml", "schema12.xml");
  SolrCore core = h.getCore();
  _parser = new SolrRequestParsers( null );
  SolrQueryResponse resp = null;
  parameters = new ModifiableSolrParams();
  parameters.set(RegexpBoostProcessor.BOOST_FILENAME_PARAM, "regex-boost-processor-test.txt");
  parameters.set(RegexpBoostProcessor.INPUT_FIELD_PARAM, "url");
  parameters.set(RegexpBoostProcessor.BOOST_FIELD_PARAM, "urlboost");
  SolrQueryRequest req = _parser.buildRequestFrom(core, new ModifiableSolrParams(), null);
  factory = new RegexpBoostProcessorFactory();
  factory.init(parameters.toNamedList());
  reProcessor = (RegexpBoostProcessor) factory.getInstance(req, resp, null);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:RegexBoostProcessorTest.java

示例11: testSetParams

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Test
public void testSetParams() {
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(HttpClientUtil.PROP_ALLOW_COMPRESSION, true);
  params.set(HttpClientUtil.PROP_BASIC_AUTH_PASS, "pass");
  params.set(HttpClientUtil.PROP_BASIC_AUTH_USER, "user");
  params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, 12345);
  params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, true);
  params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 22345);
  params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32345);
  params.set(HttpClientUtil.PROP_SO_TIMEOUT, 42345);
  params.set(HttpClientUtil.PROP_USE_RETRY, false);
  DefaultHttpClient client = (DefaultHttpClient) HttpClientUtil.createClient(params);
  assertEquals(12345, HttpConnectionParams.getConnectionTimeout(client.getParams()));
  assertEquals(PoolingClientConnectionManager.class, client.getConnectionManager().getClass());
  assertEquals(22345, ((PoolingClientConnectionManager)client.getConnectionManager()).getMaxTotal());
  assertEquals(32345, ((PoolingClientConnectionManager)client.getConnectionManager()).getDefaultMaxPerRoute());
  assertEquals(42345, HttpConnectionParams.getSoTimeout(client.getParams()));
  assertEquals(HttpClientUtil.NO_RETRY, client.getHttpRequestRetryHandler());
  assertEquals("pass", client.getCredentialsProvider().getCredentials(new AuthScope("127.0.0.1", 1234)).getPassword());
  assertEquals("user", client.getCredentialsProvider().getCredentials(new AuthScope("127.0.0.1", 1234)).getUserPrincipal().getName());
  assertEquals(true, client.getParams().getParameter(ClientPNames.HANDLE_REDIRECTS));
  client.getConnectionManager().shutdown();
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:HttpClientUtilTest.java

示例12: setDistributedParams

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
protected void setDistributedParams(ModifiableSolrParams params) {

  if (r.nextBoolean()) {
    // don't set shards, let that be figured out from the cloud state
  } else {
    // use shard ids rather than physical locations
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < shardCount; i++) {
      if (i > 0)
        sb.append(',');
      sb.append("shard" + (i + 3));
    }
    params.set("shards", sb.toString());
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:CustomCollectionTest.java

示例13: getParams

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
public SolrParams getParams() {
  if (action == null) {
    throw new RuntimeException("no action specified!");
  }
  ModifiableSolrParams params = new ModifiableSolrParams();
  params.set(CoreAdminParams.ACTION, action.toString());
  params.set(CoreAdminParams.CORE, core);
  if (indexDirs != null)  {
    for (String indexDir : indexDirs) {
      params.add(CoreAdminParams.INDEX_DIR, indexDir);
    }
  }
  if (srcCores != null) {
    for (String srcCore : srcCores) {
      params.add(CoreAdminParams.SRC_CORE, srcCore);
    }
  }
  return params;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:CoreAdminRequest.java

示例14: pingSolr

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
protected void pingSolr()
{
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set("qt", "/admin/cores");
    params.set("action", "STATUS");
	
    QueryResponse response = basicQuery(params);
    if(response != null && response.getStatus() == 0)
    {
	    NamedList<Object> results = response.getResponse();
	    @SuppressWarnings("unchecked")
              NamedList<Object> report = (NamedList<Object>)results.get("status");
	    Iterator<Map.Entry<String, Object>> coreIterator = report.iterator();
	    List<String> cores = new ArrayList<String>(report.size());
	    while(coreIterator.hasNext())
	    {
	    	Map.Entry<String, Object> core = coreIterator.next();
	    	cores.add(core.getKey());
	    }
	    
	    registerCores(cores);
    	setSolrActive(true);
    }
    else
    {
    	setSolrActive(false);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:SOLRAdminClient.java

示例15: registerBeanDefinitions

import org.apache.solr.common.params.ModifiableSolrParams; //导入方法依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    log.debug("in registerBeanDefinitions(..)");
    SolrMltInterestingTermConfiguration config = new SolrMltInterestingTermConfiguration();
    PropertiesConfigurationFactory<Object> factory = new PropertiesConfigurationFactory<Object>(config);
    factory.setTargetName("keyword");
    factory.setPropertySources(environment.getPropertySources());
    factory.setConversionService(environment.getConversionService());
    try {
        factory.bindPropertiesToTarget();
    }
    catch (BindException ex) {
        throw new FatalBeanException("Could not bind DataSourceSettings properties", ex);
    }
    ModifiableSolrParams params = new ModifiableSolrParams();
    params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 128);
    params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32);
    params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, false);
    httpClient = HttpClientUtil.createClient(params);
    config.getSolrmlt().stream().filter(SolrMltConfig::isValid).forEach(mltConfig -> {
        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(SolrMltInterestingTermExtractor.class);
        ConstructorArgumentValues constructorArguments = new ConstructorArgumentValues();
        beanDefinition.setConstructorArgumentValues(constructorArguments);
        constructorArguments.addIndexedArgumentValue(0, httpClient);
        constructorArguments.addIndexedArgumentValue(1, mltConfig);
        log.debug("register bean definition for {}", mltConfig);
        registry.registerBeanDefinition(mltConfig.getName(), beanDefinition);
    });
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:31,代码来源:SolrMltInterestingTermRegistrar.java


注:本文中的org.apache.solr.common.params.ModifiableSolrParams.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。