List of usage examples for org.apache.solr.schema IndexSchema getFields
public Map<String, SchemaField> getFields()
From source file:com.sn.solr.plugin.common.SolrHelper.java
License:Apache License
/** * Util method to return a list of fields. * /* w w w . j av a 2 s .c o m*/ * @param req {@link SolrQueryRequest} * @return {@link Set} Returns set of {@link String} field names. */ public static Set<String> getReturnFields(SolrQueryRequest req) { Set<String> fields = new HashSet<String>(); String fl = req.getParams().get(CommonParams.FL); if (fl == null || fl.equals("")) { return fields; } String[] fls = fl.split(","); IndexSchema schema = req.getSchema(); for (String f : fls) { if ("*".equals(f)) { Map<String, SchemaField> fm = schema.getFields(); for (String fieldname : fm.keySet()) { SchemaField sf = fm.get(fieldname); if (sf.stored()) { fields.add(fieldname); } } } else { fields.add(f); } } return fields; }
From source file:org.reuseware.sokan.index.solr.SolrUtil.java
License:Open Source License
/** * Checks if the given Solr schema is well formed. * //from w ww .j a v a 2 s.c om * @param schema the schema * @return true if the schema is well formed */ public static boolean wellFormed(IndexSchema schema) { Set<String> inSchema = new HashSet<String>(); for (Entry<String, SchemaField> entry : schema.getFields().entrySet()) { if (ALL_SYS_FIELDS.contains(entry.getKey())) { inSchema.add(entry.getKey()); } } if (ALL_SYS_FIELDS.size() == inSchema.size()) { return true; } return false; }
From source file:org.reuseware.sokan.index.solr.SolrUtil.java
License:Open Source License
/** * @param schema the Solr schema//w w w.j a va2 s .c om * @return all fields defined in the schema */ public static Set<String> extractFields(IndexSchema schema) { return schema.getFields().keySet(); }