当前位置: 首页>>代码示例>>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;未经允许,请勿转载。