private Map<String,SchemaField> loadSchemaFieldMap() { Map<String, SchemaField> modLnvsf = new HashMap<>(); for (Map.Entry<String, SchemaField> entry : schema.getFields().entrySet()) { modLnvsf.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue()); } return Collections.unmodifiableMap(modLnvsf); }
private SchemaField getIndexedField(String fname) { SchemaField f = getFields().get(fname); if (f==null) { throw new RuntimeException("unknown field '" + fname + "'"); } if (!f.indexed()) { throw new RuntimeException("'"+fname+"' is not an indexed field:" + f); } return f; }
protected HashMap<String,Analyzer> analyzerCache() { HashMap<String,Analyzer> cache = new HashMap<String,Analyzer>(); for (SchemaField f : getFields().values()) { Analyzer analyzer = f.getType().getAnalyzer(); cache.put(f.getName(), analyzer); } return cache; }
@Override protected HashMap<String,Analyzer> analyzerCache() { HashMap<String,Analyzer> cache = new HashMap<String,Analyzer>(); for (SchemaField f : getFields().values()) { Analyzer analyzer = f.getType().getQueryAnalyzer(); cache.put(f.getName(), analyzer); } return cache; }
public SanitizeUnknownSolrFields(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator"); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values())); String str = getConfigs().getString(config, "renameToPrefix", "").trim(); this.renameToPrefix = str.length() > 0 ? str : null; validateArguments(); }
public SanitizeUnknownSolrFields(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator"); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values())); String str = getConfigs().getString(config, "renameToPrefix", "").trim(); this.renameToPrefix = str.length() > 0 ? str : null; validateArguments(); }
public SanitizeUnknownSolrFields(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator"); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values())); String str = getConfigs().getString(config, "renameToPrefix", "").trim(); this.renameToPrefix = str.length() > 0 ? str : null; validateArguments(); }
public SanitizeUnknownSolrFields(CommandBuilder builder, Config config, Command parent, Command child, MorphlineContext context) { super(builder, config, parent, child, context); Config solrLocatorConfig = getConfigs().getConfig(config, "solrLocator"); SolrLocator locator = new SolrLocator(solrLocatorConfig, context); LOG.debug("solrLocator: {}", locator); this.schema = Objects.requireNonNull(locator.getIndexSchema()); if (LOG.isTraceEnabled()) { LOG.trace("Solr schema: \n" + schema.getFields().entrySet().stream().sorted(Map.Entry.comparingByKey()) .map(Map.Entry::getValue).map(Object::toString).collect(Collectors.joining("\n")) ); } String str = getConfigs().getString(config, "renameToPrefix", "").trim(); this.renameToPrefix = str.length() > 0 ? str : null; validateArguments(); }
private void verifyWithSchema(Map<String,EntityField> fields) { Map<String,SchemaField> schemaFields = null; if (schema == null) { schemaFields = Collections.emptyMap(); } else { schemaFields = schema.getFields(); } for (Map.Entry<String,SchemaField> entry : schemaFields.entrySet()) { SchemaField sf = entry.getValue(); if (!fields.containsKey(sf.getName())) { if (sf.isRequired()) { log.info(sf.getName() + " is a required field in SolrSchema . But not found in DataConfig"); } } } for (Map.Entry<String,EntityField> entry : fields.entrySet()) { EntityField fld = entry.getValue(); SchemaField field = getSchemaField(fld.getName()); if (field == null && !isSpecialCommand(fld.getName())) { log.info("The field :" + fld.getName() + " present in DataConfig does not have a counterpart in Solr Schema"); } } }
Map<String, SchemaField> solrFields = schema.getFields(); Set<String> schemeFieldnames = new HashSet<String>();
@Override public void inflateSolrSchema() { server = solr.solrServer(); SolrCore solrCore = solr.solrCore(); try { indexedFields = solrCore.getSchema().getFields(); } finally { solrCore.close(); } }
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(), "")); }
this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values()));
this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values()));
this.schema = locator.getIndexSchema(); Preconditions.checkNotNull(schema); LOG.trace("Solr schema: \n{}", Joiner.on("\n").join(new TreeMap(schema.getFields()).values()));
/** * Collects the document matching the given solr query request by using the given collection key function. * * @param query the plain solr query * @param req the request object * @param collectionKey the key to collected documents * @return the collected and grouped documents * @throws IOException if bad things happen */ private HashMap<ChronixType, Map<String, List<SolrDocument>>> collectDocuments(String query, SolrQueryRequest req, CQLJoinFunction collectionKey) throws IOException { //query and collect all documents Set<String> fields = getFields(req.getParams().get(CommonParams.FL), req.getSchema().getFields()); //we always need the data field fields.add(Schema.DATA); //add the involved fields from in the join key if (!isEmptyArray(collectionKey.involvedFields())) { Collections.addAll(fields, collectionKey.involvedFields()); } DocList result = docListProvider.doSimpleQuery(query, req, 0, Integer.MAX_VALUE); SolrDocumentList docs = docListProvider.docListToSolrDocumentList(result, req.getSearcher(), fields, null); return collect(docs, collectionKey); }
Map<String,SchemaField> fields = req.getSchema().getFields(); int ndocs = start + rows; Filter filter = buildFilter(fqs, req);
Map<String,SchemaField> fields = req.getSchema().getFields(); int ndocs = start + rows; Filter filter = buildFilter(fqs, req);
modifiableSolrParams.set(CommonParams.FL, requestedFields(fields, req.getSchema().getFields().keySet()));
SimpleOrderedMap<Object> fields = new SimpleOrderedMap<Object>(); SchemaField uniqueField = schema.getUniqueKeyField(); for( SchemaField f : schema.getFields().values() ) { populateFieldInfo(schema, typeusemap, fields, uniqueField, f);