本文整理汇总了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;
}
};
}
示例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
}
}
示例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());
}
示例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();
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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