Example usage for org.apache.solr.schema IndexSchema isDynamicField

List of usage examples for org.apache.solr.schema IndexSchema isDynamicField

Introduction

In this page you can find the example usage for org.apache.solr.schema IndexSchema isDynamicField.

Prototype

public boolean isDynamicField(String fieldName) 

Source Link

Document

Is the specified field dynamic or not.

Usage

From source file:org.opencms.search.solr.CmsSolrField.java

License:Open Source License

/**
 * Public constructor.<p>/*from   w  w w  .jav  a  2  s  . co m*/
 *
 * @param luceneField
 */
public CmsSolrField(CmsLuceneField luceneField) {

    super();
    String name = luceneField.getName();
    IndexSchema schema = OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema();
    if (schema.hasExplicitField(name)) {
        // take the lucene field name for Solr
    } else if ((luceneField.getType() != null)
            && schema.isDynamicField(luceneField.getName() + "_" + luceneField.getType())) {
        // try to use the specified type attribute as dynamic field suffix
        name = luceneField.getName() + "_" + luceneField.getType();
    } else {
        // fallback create a general_text field
        name = luceneField.getName() + "_txt";
    }
    setName(name);
    setBoost(luceneField.getBoost());
    setDefaultValue(luceneField.getDefaultValue());

    for (I_CmsSearchFieldMapping mapping : luceneField.getMappings()) {
        addMapping(mapping);
    }
}