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


Java SolrQueryRequest.getSchema方法代码示例

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


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

示例1: getInstance

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp,
                                          UpdateRequestProcessor next) {
  final IndexSchema schema = req.getSchema();
  return new FieldMutatingUpdateProcessor(getSelector(), next) {
    @Override
    protected SolrInputField mutate(SolrInputField src) {
      if (src.getValueCount() <= 1)
        return src;//short circuit single value
      SchemaField field = schema.getField(src.getName());
      FieldType ft = field.getType();
      IndexableField result = ft.createField(field, src, src.getBoost());
      if (result == null)
        return null;//remove
      src.setValue(result, src.getBoost());
      return src;
    }
  };
}
 
开发者ID:randomstatistic,项目名称:SOLR-5170,代码行数:21,代码来源:MultiValUpdateRequestProcessorFactory.java

示例2: testNextCursorMark

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public void testNextCursorMark() throws IOException {
  final Collection<String> allFieldNames = getAllFieldNames();
  final SolrQueryRequest req = req();
  final IndexSchema schema = req.getSchema();

  final String randomSortString = CursorPagingTest.buildRandomSort(allFieldNames);
  final SortSpec ss = QueryParsing.parseSortSpec(randomSortString, req);

  final CursorMark previous = new CursorMark(schema, ss);
  previous.parseSerializedTotem(CURSOR_MARK_START);

  List<Object> nextValues = Arrays.<Object>asList(buildRandomSortObjects(ss));
  final CursorMark next = previous.createNext(nextValues);
  assertEquals("next values not correct", nextValues, next.getSortValues());
  assertEquals("next SortSpec not correct", ss, next.getSortSpec());

  try {
    // append to our random sort string so we know it has wrong num clauses
    final SortSpec otherSort = QueryParsing.parseSortSpec(randomSortString+",id asc", req);
    CursorMark trash = previous.createNext(Arrays.<Object>asList
                                           (buildRandomSortObjects(otherSort)));
    fail("didn't fail on next with incorrect num of sortvalues");
  } catch (AssertionError e) {
    // NOOP: we're happy
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:CursorMarkTest.java

示例3: LanguageIdentifierUpdateProcessor

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public LanguageIdentifierUpdateProcessor(SolrQueryRequest req,
                                         SolrQueryResponse rsp, UpdateRequestProcessor next) {
  super(next);
  schema = req.getSchema();

  initParams(req.getParams());
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:LanguageIdentifierUpdateProcessor.java

示例4: TextResponseWriter

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public TextResponseWriter(Writer writer, SolrQueryRequest req, SolrQueryResponse rsp) {
  this.writer = FastWriter.wrap(writer);
  this.schema = req.getSchema();
  this.req = req;
  this.rsp = rsp;
  String indent = req.getParams().get("indent");
  if (indent != null && !"".equals(indent) && !"off".equals(indent)) {
    doIndent=true;
  }
  returnFields = rsp.getReturnFields();
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:TextResponseWriter.java

示例5: doAnalysis

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected NamedList doAnalysis(SolrQueryRequest req) throws Exception {
  FieldAnalysisRequest analysisRequest = resolveAnalysisRequest(req);
  IndexSchema indexSchema = req.getSchema();
  return handleAnalysisRequest(analysisRequest, indexSchema);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:FieldAnalysisRequestHandler.java

示例6: testRoundTripParsing

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public void testRoundTripParsing() throws IOException {

    // for any valid SortSpec, and any legal values, we should be able to round 
    // trip serialize the totem and get the same values back.

    final Collection<String> allFieldNames = getAllFieldNames();
    final SolrQueryRequest req = req();
    final IndexSchema schema = req.getSchema();
    final int numRandomSorts = atLeast(50);
    final int numRandomValIters = atLeast(10);
    for (int i = 0; i < numRandomSorts; i++) {
      final SortSpec ss = QueryParsing.parseSortSpec
        (CursorPagingTest.buildRandomSort(allFieldNames), req);
      final CursorMark totemIn = new CursorMark(schema, ss);
      final CursorMark totemOut = new CursorMark(schema, ss);

      // trivial case: regardless of sort, "*" should be valid and roundtrippable
      totemIn.parseSerializedTotem(CURSOR_MARK_START);
      assertEquals(CURSOR_MARK_START, totemIn.getSerializedTotem());
      // values should be null (and still roundtrippable)
      assertNull(totemIn.getSortValues());
      totemOut.setSortValues(null);
      assertEquals(CURSOR_MARK_START, totemOut.getSerializedTotem());

      for (int j = 0; j < numRandomValIters; j++) {
        final Object[] inValues = buildRandomSortObjects(ss);
        totemIn.setSortValues(Arrays.<Object>asList(inValues));
        totemOut.parseSerializedTotem(totemIn.getSerializedTotem());
        final List<Object> out = totemOut.getSortValues();
        assertNotNull(out);
        final Object[] outValues = out.toArray();
        assertArrayEquals(inValues, outValues);
      }
    }
  }
 
开发者ID:europeana,项目名称:search,代码行数:36,代码来源:CursorMarkTest.java

示例7: getInstance

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
    SolrQueryResponse rsp, UpdateRequestProcessor next) {
  return new PreAnalyzedUpdateProcessor(getSelector(), next, req.getSchema(), parser);
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:PreAnalyzedUpdateProcessorFactory.java

示例8: SimpleQParser

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public SimpleQParser (String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {

      super(qstr, localParams, params, req);
      // Some of the parameters may come in through localParams, so combine them with params.
      SolrParams defaultParams = SolrParams.wrapDefaults(localParams, params);

      // This will be used to specify what fields and boosts will be used by SimpleQueryParser.
      Map<String, Float> queryFields = SolrPluginUtils.parseFieldBoosts(defaultParams.get(SimpleParams.QF));

      if (queryFields.isEmpty()) {
        // It qf is not specified setup up the queryFields map to use the defaultField.
        String defaultField = QueryParsing.getDefaultField(req.getSchema(), defaultParams.get(CommonParams.DF));

        if (defaultField == null) {
          // A query cannot be run without having a field or set of fields to run against.
          throw new IllegalStateException("Neither " + SimpleParams.QF + ", " + CommonParams.DF
              + ", nor the default search field are present.");
        }

        queryFields.put(defaultField, 1.0F);
      }
      else {
        for (Map.Entry<String, Float> queryField : queryFields.entrySet()) {
          if (queryField.getValue() == null) {
            // Some fields may be specified without a boost, so default the boost to 1.0 since a null value
            // will not be accepted by SimpleQueryParser.
            queryField.setValue(1.0F);
          }
        }
      }

      // Setup the operations that are enabled for the query.
      int enabledOps = 0;
      String opParam = defaultParams.get(SimpleParams.QO);

      if (opParam == null) {
        // All operations will be enabled.
        enabledOps = -1;
      } else {
        // Parse the specified enabled operations to be used by the query.
        String[] operations = opParam.split(",");

        for (String operation : operations) {
          Integer enabledOp = OPERATORS.get(operation.trim().toUpperCase(Locale.ROOT));

          if (enabledOp != null) {
            enabledOps |= enabledOp;
          }
        }
      }

      // Create a SimpleQueryParser using the analyzer from the schema.
      final IndexSchema schema = req.getSchema();
      parser = new SolrSimpleQueryParser(req.getSchema().getQueryAnalyzer(), queryFields, enabledOps, this, schema);

      // Set the default operator to be either 'AND' or 'OR' for the query.
      QueryParser.Operator defaultOp = QueryParsing.getQueryParserDefaultOperator(req.getSchema(), defaultParams.get(QueryParsing.OP));

      if (defaultOp == QueryParser.Operator.AND) {
        parser.setDefaultOperator(BooleanClause.Occur.MUST);
      }
    }
 
开发者ID:europeana,项目名称:search,代码行数:63,代码来源:SimpleQParserPlugin.java

示例9: SolrExtendedPostingsHighlighter

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public SolrExtendedPostingsHighlighter(SolrQueryRequest req) {
  super(req.getParams().getInt(HighlightParams.MAX_CHARS, PostingsHighlighter.DEFAULT_MAX_LENGTH));
  this.params = req.getParams();
  this.schema = req.getSchema();
}
 
开发者ID:europeana,项目名称:search,代码行数:6,代码来源:PostingsSolrHighlighter.java

示例10: MultiLangIdentifierUpdateProcessor

import org.apache.solr.request.SolrQueryRequest; //导入方法依赖的package包/类
public MultiLangIdentifierUpdateProcessor(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) {
    super(next);
    this.schema = req.getSchema();
    this.setting = MultiLangIdentifierSettingHelper.valueOf(req.getParams());
}
 
开发者ID:smalldirector,项目名称:solr-multilingual-analyzer,代码行数:6,代码来源:MultiLangIdentifierUpdateProcessor.java


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