protected void init(IndexSchema schema, Map<String,String> args) { restrictProps(SORT_MISSING_FIRST | SORT_MISSING_LAST); String ftypeS = getArg("valType", args); if (ftypeS!=null) { ftype = schema.getFieldTypes().get(ftypeS); if (ftype==null || !(ftype instanceof FloatField)) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Only float (FloatField) is currently supported as external field type. got " + ftypeS); } } keyFieldName = args.remove("keyField"); String defValS = args.remove("defVal"); defVal = defValS==null ? 0 : Float.parseFloat(defValS); this.schema = schema; }
protected void checkAllowLeadingWildcards() { boolean allow = false; for (Entry<String, FieldType> e : schema.getFieldTypes().entrySet()) { Analyzer a = e.getValue().getAnalyzer(); if (a instanceof TokenizerChain) { // examine the indexing analysis chain if it supports leading wildcards TokenizerChain tc = (TokenizerChain)a; TokenFilterFactory[] factories = tc.getTokenFilterFactories(); for (TokenFilterFactory factory : factories) { if (factory instanceof ReversedWildcardFilterFactory) { allow = true; leadingWildcards.put(e.getKey(), (ReversedWildcardFilterFactory)factory); } } } } // XXX should be enabled on a per-field basis if (allow) { setAllowLeadingWildcard(true); } }
if (schema.getFieldTypes().containsKey(args.get(DEFAULT_FIELDTYPE))){ defaultFieldTypeName = args.get(DEFAULT_FIELDTYPE); if (!schema.getFieldTypes().containsKey(fieldType)){ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Schema configuration error for " + this.getClass().getSimpleName()
if (schema.getFieldTypes().containsKey(suggestionAnalyzerFieldTypeName)) { FieldType fieldType = schema.getFieldTypes().get(suggestionAnalyzerFieldTypeName); suggestionAnalyzer = fieldType.getQueryAnalyzer();
FieldType fieldType = schema.getFieldTypes() .get(fieldTypeName);
private void informField (FieldDefinition xmlField, SolrCore core) { Map<String,SchemaField> schemaFields = schema.getFields(); Map<String,FieldType> fieldTypes = schema.getFieldTypes(); String fieldName = xmlField.getName(); if (schemaFields.containsKey(fieldName) && xmlField.getType() != Type.TOKENS) { // The Solr schema has a definition for this field, but it's not a TOKENS field: // We're only interested in TOKENS fields here; these need to install their own special field type since they wrap the // analyzer defined by the schema return; } // look up the type of this field using the mapping in this class FieldType fieldType = getFieldType(xmlField); if (! fieldTypes.containsKey(fieldType.getTypeName())) { // The Solr schema does not define this field type, so add it logger.info("{} defining fieldType: {}", core.getName(), fieldType.getTypeName()); fieldTypes.put(fieldType.getTypeName(), fieldType); } else { fieldType = fieldTypes.get(fieldType.getTypeName()); } // Add the field to the schema logger.info(core.getName() + " defining field: {} of type {}", fieldName, fieldType.getTypeName()); schemaFields.put(fieldName, new SchemaField (fieldName, fieldType, xmlField.getSolrFieldProperties(), "")); }
IndexSchema schema = core.getLatestSchema(); String fieldTypeName = (String) initParams.get("queryAnalyzerFieldType"); FieldType fieldType = schema.getFieldTypes().get(fieldTypeName); Analyzer analyzer = fieldType == null ? new WhitespaceAnalyzer() : fieldType.getQueryAnalyzer();
IndexSchema schema = core.getSchema(); String fieldTypeName = (String) initParams.get("queryAnalyzerFieldType"); FieldType fieldType = schema.getFieldTypes().get(fieldTypeName); Analyzer analyzer = fieldType == null ? new WhitespaceAnalyzer() : fieldType.getQueryAnalyzer();
if (core.getSchema().getFieldTypes().containsKey(fieldTypeName)) { FieldType fieldType = core.getSchema().getFieldTypes().get(fieldTypeName); analyzer = fieldType.getQueryAnalyzer();
FieldType ft = core.getSchema().getFieldTypes().get( a ); if( ft == null ) { throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
for( FieldType ft : schema.getFieldTypes().values() ) { SimpleOrderedMap<Object> field = new SimpleOrderedMap<Object>(); field.add("fields", typeusemap.get( ft.getTypeName() ) );
/** * Handles the resolved analysis request and returns the analysis breakdown response as a named list. * * @param request The request to handle. * @param schema The index schema. * * @return The analysis breakdown as a named list. */ protected NamedList<NamedList> handleAnalysisRequest(FieldAnalysisRequest request, IndexSchema schema) { NamedList<NamedList> analysisResults = new SimpleOrderedMap<NamedList>(); NamedList<NamedList> fieldTypeAnalysisResults = new SimpleOrderedMap<NamedList>(); if (request.getFieldTypes() != null) { for (String fieldTypeName : request.getFieldTypes()) { FieldType fieldType = schema.getFieldTypes().get(fieldTypeName); fieldTypeAnalysisResults.add(fieldTypeName, analyzeValues(request, fieldType, null)); } } NamedList<NamedList> fieldNameAnalysisResults = new SimpleOrderedMap<NamedList>(); if (request.getFieldNames() != null) { for (String fieldName : request.getFieldNames()) { FieldType fieldType = schema.getFieldType(fieldName); fieldNameAnalysisResults.add(fieldName, analyzeValues(request, fieldType, fieldName)); } } analysisResults.add("field_types", fieldTypeAnalysisResults); analysisResults.add("field_names", fieldNameAnalysisResults); return analysisResults; }