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


Java SolrException類代碼示例

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


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

示例1: getMatchesFromQuery

import org.apache.solr.common.SolrException; //導入依賴的package包/類
private RFResult getMatchesFromQuery(SolrQueryResponse rsp, SolrParams params, int flags, String q, Query query, Query userQuery, SortSpec sortSpec, List<Query> targetFqFilters, List<Query> rfFqFilters, SolrIndexSearcher searcher, RFHelper rfHelper, int start, int rows) throws IOException, SyntaxError {

        boolean includeMatch = params.getBool(RFParams.MATCH_INCLUDE, true);
        int matchOffset = params.getInt(RFParams.MATCH_OFFSET, 0);
        // Find the base match
        DocList match = searcher.getDocList(query, targetFqFilters, null, matchOffset, 10000, flags); // only get the first one...
        if(match.matches() == 0 && userQuery == null){
            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
                    String.format("RelevancyFeedback was unable to find any documents matching the query: '%s'.", q));
        }

        if (includeMatch) {
            rsp.add("match", match);
        }

        // This is an iterator, but we only handle the first match
        DocIterator iterator = match.iterator();
        if (iterator.hasNext() || userQuery != null) {
            // do a RelevancyFeedback query for each document in results
            return rfHelper.getMatchesFromDocs(iterator, start, rows, rfFqFilters, flags, sortSpec.getSort(), userQuery);
        }
        return null;
    }
 
開發者ID:DiceTechJobs,項目名稱:RelevancyFeedback,代碼行數:24,代碼來源:RelevancyFeedbackHandler.java

示例2: download

import org.apache.solr.common.SolrException; //導入依賴的package包/類
public SimpleOrderedMap<Object> download(long procId, boolean delete){
  SimpleOrderedMap<Object> data = null;

  synchronized (managers){
    FeaturesExtractorManager manager = managers.get(procId);
    if(manager == null){
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, String.format("no such process (procId=%d)", procId));
    }
    else{
      data = manager.getResult();
      if(delete){
        manager.delete();
        managers.remove(procId);
      }
    }
  }

  return data;
}
 
開發者ID:NLP4L,項目名稱:solr,代碼行數:20,代碼來源:FeaturesRequestHandler.java

示例3: getGroupedFacetQueryCount

import org.apache.solr.common.SolrException; //導入依賴的package包/類
/**
 * Returns a grouped facet count for the facet query
 *
 * @see FacetParams#FACET_QUERY
 */
public int getGroupedFacetQueryCount(Query facetQuery, DocSet docSet) throws IOException {
  // It is okay to retrieve group.field from global because it is never a local param
  String groupField = global.get(GroupParams.GROUP_FIELD);
  if (groupField == null) {
    throw new SolrException (
        SolrException.ErrorCode.BAD_REQUEST,
        "Specify the group.field as parameter or local parameter"
    );
  }

  TermAllGroupsCollector collector = new TermAllGroupsCollector(groupField);
  Filter mainQueryFilter = docSet.getTopFilter(); // This returns a filter that only matches documents matching with q param and fq params
  Query filteredFacetQuery = new BooleanQuery.Builder()
      .add(facetQuery, Occur.MUST)
      .add(mainQueryFilter, Occur.FILTER)
      .build();
  searcher.search(filteredFacetQuery, collector);
  return collector.getGroupCount();
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:25,代碼來源:SimpleFacets.java

示例4: selectFacetMethod

import org.apache.solr.common.SolrException; //導入依賴的package包/類
/**
  * @param existsRequested facet.exists=true is passed for the given field
  * */
static FacetMethod selectFacetMethod(String fieldName, 
                                     SchemaField field, FacetMethod method, Integer mincount,
                                     boolean existsRequested) {
  if (existsRequested) {
    checkMincountOnExists(fieldName, mincount);
    if (method == null) {
      method = FacetMethod.ENUM;
    }
  }
  final FacetMethod facetMethod = selectFacetMethod(field, method, mincount);
  
  if (existsRequested && facetMethod!=FacetMethod.ENUM) {
    throw new SolrException (ErrorCode.BAD_REQUEST, 
        FacetParams.FACET_EXISTS + "=true is requested, but "+
        FacetParams.FACET_METHOD+"="+FacetParams.FACET_METHOD_enum+ " can't be used with "+fieldName
    );
  }
  return facetMethod;
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:23,代碼來源:SimpleFacets.java

示例5: getHeatmapCounts

import org.apache.solr.common.SolrException; //導入依賴的package包/類
public NamedList getHeatmapCounts() throws IOException, SyntaxError {
  final NamedList<Object> resOuter = new SimpleOrderedMap<>();
  String[] unparsedFields = rb.req.getParams().getParams(FacetParams.FACET_HEATMAP);
  if (unparsedFields == null || unparsedFields.length == 0) {
    return resOuter;
  }
  if (global.getBool(GroupParams.GROUP_FACET, false)) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
        "Heatmaps can't be used with " + GroupParams.GROUP_FACET);
  }
  for (String unparsedField : unparsedFields) {
    final ParsedParams parsed = parseParams(FacetParams.FACET_HEATMAP, unparsedField); // populates facetValue, rb, params, docs

    resOuter.add(parsed.key, SpatialHeatmapFacets.getHeatmapForField(parsed.key, parsed.facetValue, rb, parsed.params, parsed.docs));
  }
  return resOuter;
}
 
開發者ID:upenn-libraries,項目名稱:solrplugins,代碼行數:18,代碼來源:SimpleFacets.java

示例6: setResultValue

import org.apache.solr.common.SolrException; //導入依賴的package包/類
private void setResultValue(ResponseValue toSet, double result, QueryWaitable.QueryType type)
{
    switch(type)
    {
        case FG:
            toSet.foreground_popularity = result;
            break;
        case BG:
            toSet.background_popularity = result;
            break;
        case Q:
            toSet.popularity = result;
            break;
        default:
            throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown QueryType.");
    }
}
 
開發者ID:careerbuilder,項目名稱:semantic-knowledge-graph,代碼行數:18,代碼來源:NodeScorer.java

示例7: validate_TwoTrunkTreeCompareException

import org.apache.solr.common.SolrException; //導入依賴的package包/類
@Test(expected = SolrException.class)
public void validate_TwoTrunkTreeCompareException() throws IOException {
    new MockUp<ParseUtility>() {
        @Mock
        private Query parseQueryString(String qString, SolrQueryRequest req)
        {
            return new MatchAllDocsQuery();
        }
    };
    KnowledgeGraphRequest request = new KnowledgeGraphRequest(
            new RequestNode[2]);
    request.queries = new String[] { "test" };
    request.normalize=true;
    request.compare[0] = new RequestNode(null, "testType0");
    request.compare[1] = new RequestNode(null, "testType1");
    request.compare[0].compare = new RequestNode[2];
    request.compare[0].compare[0] = new RequestNode();
    request.compare[0].compare[1] = new RequestNode(null, "testType01");
    RequestValidator target = new RequestValidator(solrRequest, request);
    target.validate();
}
 
開發者ID:careerbuilder,項目名稱:semantic-knowledge-graph,代碼行數:22,代碼來源:RequestValidatorTest.java

示例8: getMainValuePrefix

import org.apache.solr.common.SolrException; //導入依賴的package包/類
/** expert internal use, subject to change.
 * Returns null if no prefix or prefix not needed, or the prefix of the main value of a trie field
 * that indexes multiple precisions per value.
 */
public static String getMainValuePrefix(org.apache.solr.schema.FieldType ft) {
  if (ft instanceof TrieDateField)
    ft = ((TrieDateField) ft).wrappedField;
  if (ft instanceof TrieField) {
    final TrieField trie = (TrieField)ft;
    if (trie.precisionStep  == Integer.MAX_VALUE)
      return null;
    switch (trie.type) {
      case INTEGER:
      case FLOAT:
        return INT_PREFIX;
      case LONG:
      case DOUBLE:
      case DATE:
        return LONG_PREFIX;
      default:
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown type for trie field: " + trie.type);
    }
  }
  return null;
}
 
開發者ID:europeana,項目名稱:search,代碼行數:26,代碼來源:TrieField.java

示例9: inform

import org.apache.solr.common.SolrException; //導入依賴的package包/類
@Override
public void inform(SolrCore core) {
  final SchemaField field = core.getLatestSchema().getFieldOrNull(getSignatureField());
  if (null == field) {
    throw new SolrException
      (ErrorCode.SERVER_ERROR,
       "Can't use signatureField which does not exist in schema: "
       + getSignatureField());
  }

  if (getOverwriteDupes() && ( ! field.indexed() ) ) {
    throw new SolrException
      (ErrorCode.SERVER_ERROR,
       "Can't set overwriteDupes when signatureField is not indexed: "
       + getSignatureField());
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:18,代碼來源:SignatureUpdateProcessorFactory.java

示例10: testParameterIncompatibilityException2

import org.apache.solr.common.SolrException; //導入依賴的package包/類
@Test
public void testParameterIncompatibilityException2() throws Exception
{
  HttpServletRequest request = createMock(HttpServletRequest.class);
  expect(request.getMethod()).andReturn("POST").anyTimes();
  expect(request.getContentType()).andReturn("application/x-www-form-urlencoded").anyTimes();
  expect(request.getContentLength()).andReturn(100).anyTimes();
  expect(request.getQueryString()).andReturn(null).anyTimes();
  // we emulate Tomcat that throws IllegalStateException when parameters were parsed before:
  expect(request.getInputStream()).andThrow(new IllegalStateException());
  replay(request);
  
  FormDataRequestParser formdata = new FormDataRequestParser( 2048 );    
  try {
    formdata.parseParamsAndFillStreams(request, new ArrayList<ContentStream>());
    fail("should throw SolrException");
  } catch (SolrException solre) {
    assertTrue(solre.getMessage().startsWith("Solr requires that request parameters"));
    assertEquals(500, solre.code());
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:SolrRequestParserTest.java

示例11: createIndexSchema

import org.apache.solr.common.SolrException; //導入依賴的package包/類
@Override
public IndexSchema createIndexSchema(final CoreDescriptor cd, final SolrConfig solrConfig) {
  final String resourceNameToBeUsed = IndexSchemaFactory.getResourceNameToBeUsed(cd.getSchemaName(), solrConfig);
  File schemaFile = new File(resourceNameToBeUsed);
  if (!schemaFile.isAbsolute()) {
    schemaFile = new File(solrConfig.getResourceLoader().getConfigDir(), schemaFile.getPath());
  }
  if (schemaFile.exists()) {
    try {
      return schemaCache.get(cacheName(schemaFile), new Callable<IndexSchema>() {
        @Override
        public IndexSchema call() throws Exception {
          logger.info("Creating new index schema for core {}", cd.getName());
          return IndexSchemaFactory.buildIndexSchema(cd.getSchemaName(), solrConfig);
        }
      });
    } catch (ExecutionException e) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
          "Error creating index schema for core " + cd.getName(), e);
    }
  }
  return IndexSchemaFactory.buildIndexSchema(cd.getSchemaName(), solrConfig);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:24,代碼來源:ConfigSetService.java

示例12: reload

import org.apache.solr.common.SolrException; //導入依賴的package包/類
/**
 * Recreates a SolrCore.
 * While the new core is loading, requests will continue to be dispatched to
 * and processed by the old core
 * 
 * @param name the name of the SolrCore to reload
 */
public void reload(String name) {

  name = checkDefault(name);

  SolrCore core = solrCores.getCoreFromAnyList(name, false);
  if (core == null)
    throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "No such core: " + name );

  CoreDescriptor cd = core.getCoreDescriptor();
  try {
    solrCores.waitAddPendingCoreOps(name);
    ConfigSet coreConfig = coreConfigService.getConfig(cd);
    log.info("Reloading SolrCore '{}' using configuration from {}", cd.getName(), coreConfig.getName());
    SolrCore newCore = core.reload(coreConfig);
    registerCore(name, newCore, false);
  }
  catch (Exception e) {
    coreInitFailures.put(cd.getName(), new CoreLoadFailure(cd, e));
    throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to reload core [" + cd.getName() + "]", e);
  }
  finally {
    solrCores.removeFromPendingOps(name);
  }

}
 
開發者ID:europeana,項目名稱:search,代碼行數:33,代碼來源:CoreContainer.java

示例13: tryCreateFail

import org.apache.solr.common.SolrException; //導入依賴的package包/類
private void tryCreateFail(CoreAdminHandler admin, String name, String dataDir, String... errs) throws Exception {
  try {
    SolrQueryResponse resp = new SolrQueryResponse();

    SolrQueryRequest request = req(CoreAdminParams.ACTION,
        CoreAdminParams.CoreAdminAction.CREATE.toString(),
        CoreAdminParams.DATA_DIR, dataDir,
        CoreAdminParams.NAME, name,
        "schema", "schema.xml",
        "config", "solrconfig.xml");

    admin.handleRequestBody(request, resp);
    fail("Should have thrown an error");
  } catch (SolrException se) {
    //SolrException cause = (SolrException)se.getCause();
    assertEquals("Exception code should be 500", 500, se.code());
    for (String err : errs) {
     assertTrue("Should have seen an exception containing the an error",
          se.getMessage().contains(err));
    }
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:23,代碼來源:TestLazyCores.java

示例14: parseSingleFieldValue

import org.apache.solr.common.SolrException; //導入依賴的package包/類
private Object parseSingleFieldValue(int ev) throws IOException {
  switch (ev) {
    case JSONParser.STRING:
      return parser.getString();
    case JSONParser.LONG:
      return parser.getLong();
    case JSONParser.NUMBER:
      return parser.getDouble();
    case JSONParser.BIGNUMBER:
      return parser.getNumberChars().toString();
    case JSONParser.BOOLEAN:
      return parser.getBoolean();
    case JSONParser.NULL:
      parser.getNull();
      return null;
    case JSONParser.ARRAY_START:
      return parseArrayFieldValue(ev);
    default:
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing JSON field value. Unexpected "+JSONParser.getEventString(ev) );
  }
}
 
開發者ID:europeana,項目名稱:search,代碼行數:22,代碼來源:JsonLoader.java

示例15: buildCollection

import org.apache.solr.common.SolrException; //導入依賴的package包/類
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
  String collection = message.getStr("name");
  log.info("building a new collection: " + collection);
  if(clusterState.hasCollection(collection) ){
    log.warn("Collection {} already exists. exit" ,collection);
    return clusterState;
  }

  ArrayList<String> shardNames = new ArrayList<>();

  if(ImplicitDocRouter.NAME.equals( message.getStr("router.name",DocRouter.DEFAULT_NAME))){
    getShardNames(shardNames,message.getStr("shards",DocRouter.DEFAULT_NAME));
  } else {
    int numShards = message.getInt(ZkStateReader.NUM_SHARDS_PROP, -1);
    if(numShards<1) throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"numShards is a required parameter for 'compositeId' router");
    getShardNames(numShards, shardNames);
  }

  return createCollection(clusterState,collection,shardNames,message);
}
 
開發者ID:europeana,項目名稱:search,代碼行數:21,代碼來源:Overseer.java


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