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


Java SolrParams類代碼示例

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


SolrParams類屬於org.apache.solr.common.params包,在下文中一共展示了SolrParams類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fetchExistingOrCreateNewSolrDoc

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
private SolrInputDocument fetchExistingOrCreateNewSolrDoc(String id) throws SolrServerException, IOException {
  Map<String, String> p = new HashMap<String, String>();
  p.put("q", PHRASE + ":\"" + ClientUtils.escapeQueryChars(id) + "\"");
  
  SolrParams params = new MapSolrParams(p);
  
  QueryResponse res = solrAC.query(params);
  
  if (res.getResults().size() == 0) {
    return new SolrInputDocument();
  } else if (res.getResults().size() == 1) {
    SolrDocument doc = res.getResults().get(0);
    SolrInputDocument tmp = new SolrInputDocument();
    
    for (String fieldName : doc.getFieldNames()) {
      tmp.addField(fieldName, doc.getFieldValue(fieldName));
    }
    return tmp;
  } else {
    throw new IllegalStateException("Query with params : " + p + " returned more than 1 hit!");
  }
}
 
開發者ID:sematext,項目名稱:solr-autocomplete,代碼行數:23,代碼來源:AutocompleteUpdateRequestProcessor.java

示例2: checkParams

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
private boolean checkParams(SolrParams params){

        if(params.get(config_query_method) == null){
            return false;
        }

        String type;
        if((type = params.get(config_api_type)) != null){
            if(type.equals("mock")){
                return true;
            }
            if(type.equals("real")) {
                if(params.get(config_url) != null){
                    return true;
                }
            }
        }

        return false;
    }
 
開發者ID:sebastian-hofstaetter,項目名稱:ir-generalized-translation-models,代碼行數:21,代碼來源:SimilarityParser.java

示例3: newFrom

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
/**
 * Creates a new {@link SolrQueryRequest} from a given prototype and injects there a set of params. 
 * 
 * @param request the prototype {@link SolrQueryRequest}.
 * @param params the parameters that will be injected.
 * @return a {@link SolrQueryRequest} clone.
 */
public SolrQueryRequest newFrom(final SolrQueryRequest request, final SolrParams params) {
	return new SolrQueryRequestBase(
			request.getCore(), 
			new ModifiableSolrParams(params), 
			new RTimerTree()) {
		@Override
		public Map<Object, Object> getContext() {
			return request.getContext();
		}
		
		@Override
		public SolrIndexSearcher getSearcher() {
			return request.getSearcher();
		}
	};
}
 
開發者ID:spaziocodice,項目名稱:invisible-queries-request-handler,代碼行數:24,代碼來源:InvisibleQueriesRequestHandler.java

示例4: relaxMM

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
@Override
public String relaxMM(SolrParams params, String relaxedMM) {
  String query = params.get(CommonParams.Q);
  String field = params.get(RelaxerParams.QUERY_RELAXER_FIELD);

  Matcher matcher = SUB_QUERY.matcher(query);
  while (matcher.find()) {
    String subQuery = matcher.group();
    String relax = match(RELAX, subQuery);
    int start = matcher.start();

    if ("ON".equalsIgnoreCase(relax)) {
      return replaceOrInsert(MM, query, start, subQuery, relaxedMM);
    }

    String queryFields = match(QUERY_FIELDS, subQuery);
    if (queryFields != null) {
      Set<String> fields = matchAll(FIELDS, queryFields);
      if (fields.contains(field)) {
        return replaceOrInsert(MM, query, start, subQuery, relaxedMM);
      }
    }
  }
  
  return query;
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:27,代碼來源:RegexExtractor.java

示例5: testRelaxMM

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
@Test
public void testRelaxMM() {
  Map<String, String> m = new HashMap<String, String>();
  m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on'}\" +yearpub:2008");
  SolrParams params = new MapSolrParams(m);
  String relaxedQuery = extract.relaxMM(params, "-1");
  assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='-1'}\" +yearpub:2008", relaxedQuery);
  
  m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='100%'}\" +yearpub:2008");
  relaxedQuery = extract.relaxMM(params, "-1");
  assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' relax='on' mm='-1'}\" +yearpub:2008", relaxedQuery);
  
  m.put("q", "query:\"{!type=edismax qf='title description body' v='large rectangle' mm='100%'}\" +yearpub:2008");
  relaxedQuery = extract.relaxMM(params, "-1");
  assertEquals("query:\"{!type=edismax qf='title description body' v='large rectangle' mm='100%'}\" +yearpub:2008", relaxedQuery);
}
 
開發者ID:sematext,項目名稱:solr-researcher,代碼行數:17,代碼來源:TestRegexExtract.java

示例6: ParsedParams

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
public ParsedParams(final SolrParams localParams, // localParams on this particular facet command
                    final SolrParams params,      // local+original
                    final SolrParams required,    // required version of params
                    final String facetValue,      // the field to or query to facet on (minus local params)
                    final DocSet docs,            // the base docset for this particular facet
                    final String key,             // what name should the results be stored under
                    final List<String> tags,
                    final int threads) {
  this.localParams = localParams;
  this.params = params;
  this.required = required;
  this.facetValue = facetValue;
  this.docs = docs;
  this.key = key;
  this.tags = tags;
  this.threads = threads;
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:18,代碼來源:SimpleFacets.java

示例7: newBytesRefFilter

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
protected Predicate<BytesRef> newBytesRefFilter(String field, SolrParams params) {
  final String contains = params.getFieldParam(field, FacetParams.FACET_CONTAINS);

  final Predicate<BytesRef> containsFilter;
  if (contains != null) {
    final boolean containsIgnoreCase = params.getFieldBool(field, FacetParams.FACET_CONTAINS_IGNORE_CASE, false);
    containsFilter = new SubstringBytesRefFilter(contains, containsIgnoreCase);
  } else {
    containsFilter = null;
  }

  final Predicate<BytesRef> excludeFilter = newExcludeBytesRefFilter(field, params);

  if (containsFilter == null && excludeFilter == null) {
    return null;
  }

  if (containsFilter != null && excludeFilter == null) {
    return containsFilter;
  } else if (containsFilter == null && excludeFilter != null) {
    return excludeFilter;
  }

  return containsFilter.and(excludeFilter);
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:26,代碼來源:SimpleFacets.java

示例8: configure

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
protected void configure(DefaultHttpClient httpClient, SolrParams config) {
  super.configure(httpClient, config);
  // Begin change for SDC-2962
  // Instead of checking existence of JAAS file, do the following if solr kerberos is enabled
  //if(System.getProperty("java.security.auth.login.config") != null) {
    String basicAuthUser = config.get("httpBasicAuthUser");
    String basicAuthPass = config.get("httpBasicAuthPassword");
    if(basicAuthUser != null && basicAuthPass != null) {
      logger.warn("Setting both SPNego auth and basic auth not supported.  Preferring SPNego auth, ignoring basic auth.");
      httpClient.getCredentialsProvider().clear();
    }

    setSPNegoAuth(httpClient);
  //}

}
 
開發者ID:streamsets,項目名稱:datacollector,代碼行數:17,代碼來源:SdcKrb5HttpClientConfigurer.java

示例9: getParams

import org.apache.solr.common.params.SolrParams; //導入依賴的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

示例10: fillParams

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
protected void fillParams(ResponseBuilder rb, SolrParams params, String field) {
  this.field = field;
  this.ftype = rb.req.getSchema().getFieldTypeNoEx(this.field);
  this.offset = params.getFieldInt(field, FacetParams.FACET_OFFSET, 0);
  this.limit = params.getFieldInt(field, FacetParams.FACET_LIMIT, 100);
  Integer mincount = params.getFieldInt(field, FacetParams.FACET_MINCOUNT);
  if (mincount == null) {
    Boolean zeros = params.getFieldBool(field, FacetParams.FACET_ZEROS);
    // mincount = (zeros!=null && zeros) ? 0 : 1;
    mincount = (zeros != null && !zeros) ? 1 : 0;
    // current default is to include zeros.
  }
  this.minCount = mincount;
  this.missing = params.getFieldBool(field, FacetParams.FACET_MISSING, false);
  // default to sorting by count if there is a limit.
  this.sort = params.getFieldParam(field, FacetParams.FACET_SORT,
                                   (limit > 0 ? 
                                    FacetParams.FACET_SORT_COUNT
                                    : FacetParams.FACET_SORT_INDEX));
  if (this.sort.equals(FacetParams.FACET_SORT_COUNT_LEGACY)) {
    this.sort = FacetParams.FACET_SORT_COUNT;
  } else if (this.sort.equals(FacetParams.FACET_SORT_INDEX_LEGACY)) {
    this.sort = FacetParams.FACET_SORT_INDEX;
  }
  this.prefix = params.getFieldParam(field, FacetParams.FACET_PREFIX);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:27,代碼來源:FacetComponent.java

示例11: handleRequestActionStatus

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
/**
 * Handle "REQUESTSTATUS" action
 */
protected void handleRequestActionStatus(SolrQueryRequest req, SolrQueryResponse rsp) {
  SolrParams params = req.getParams();
  String requestId = params.get(CoreAdminParams.REQUESTID);
  log.info("Checking request status for : " + requestId);

  if (mapContainsTask(RUNNING, requestId)) {
    rsp.add(RESPONSE_STATUS, RUNNING);
  } else if(mapContainsTask(COMPLETED, requestId)) {
    rsp.add(RESPONSE_STATUS, COMPLETED);
    rsp.add(RESPONSE, getMap(COMPLETED).get(requestId).getRspObject());
  } else if(mapContainsTask(FAILED, requestId)) {
    rsp.add(RESPONSE_STATUS, FAILED);
    rsp.add(RESPONSE, getMap(FAILED).get(requestId).getRspObject());
  } else {
    rsp.add(RESPONSE_STATUS, "notfound");
    rsp.add(RESPONSE_MESSAGE, "No task found in running, completed or failed tasks");
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:CoreAdminHandler.java

示例12: prepare

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
@Override
public void prepare(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  rb.doHighlights = highlighter.isHighlightingEnabled(params);
  if(rb.doHighlights){
    String hlq = params.get(HighlightParams.Q);
    String hlparser = Objects.firstNonNull(params.get(HighlightParams.QPARSER),
                                            params.get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE));
    if(hlq != null){
      try {
        QParser parser = QParser.getParser(hlq, hlparser, rb.req);
        rb.setHighlightQuery(parser.getHighlightQuery());
      } catch (SyntaxError e) {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
      }
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:19,代碼來源:HighlightComponent.java

示例13: JQ

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
/** Makes a query request and returns the JSON string response */
public static String JQ(SolrQueryRequest req) throws Exception {
  SolrParams params = req.getParams();
  if (!"json".equals(params.get("wt","xml")) || params.get("indent")==null) {
    ModifiableSolrParams newParams = new ModifiableSolrParams(params);
    newParams.set("wt","json");
    if (params.get("indent")==null) newParams.set("indent","true");
    req.setParams(newParams);
  }

  String response;
  boolean failed=true;
  try {
    response = h.query(req);
    failed = false;
  } finally {
    if (failed) {
      log.error("REQUEST FAILED: " + req.getParamString());
    }
  }

  return response;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:24,代碼來源:SolrTestCaseJ4.java

示例14: prepare

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void prepare(ResponseBuilder rb) throws IOException {

  SolrParams params = rb.req.getParams();
  if (!params.getBool(COMPONENT_NAME, false)) {
    return;
  }
  SolrSpellChecker spellChecker = getSpellChecker(params);
  if (params.getBool(SPELLCHECK_BUILD, false)) {
    spellChecker.build(rb.req.getCore(), rb.req.getSearcher());
    rb.rsp.add("command", "build");
  } else if (params.getBool(SPELLCHECK_RELOAD, false)) {
    spellChecker.reload(rb.req.getCore(), rb.req.getSearcher());
    rb.rsp.add("command", "reload");
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:18,代碼來源:SpellCheckComponent.java

示例15: setUrlScheme

import org.apache.solr.common.params.SolrParams; //導入依賴的package包/類
private void setUrlScheme(String value) throws Exception {
  @SuppressWarnings("rawtypes")
  Map m = makeMap("action", CollectionAction.CLUSTERPROP.toString()
      .toLowerCase(Locale.ROOT), "name", "urlScheme", "val", value);
  @SuppressWarnings("unchecked")
  SolrParams params = new MapSolrParams(m);
  SolrRequest request = new QueryRequest(params);
  request.setPath("/admin/collections");
  
  List<String> urls = new ArrayList<String>();
  for(Replica replica : getReplicas()) {
    urls.add(replica.getStr(ZkStateReader.BASE_URL_PROP));
  }
  //Create new SolrServer to configure new HttpClient w/ SSL config
  new LBHttpSolrServer(urls.toArray(new String[]{})).request(request);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:17,代碼來源:SSLMigrationTest.java


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