Example usage for org.apache.lucene.queryparser.flexible.standard.config FieldDateResolutionFCListener FieldDateResolutionFCListener

List of usage examples for org.apache.lucene.queryparser.flexible.standard.config FieldDateResolutionFCListener FieldDateResolutionFCListener

Introduction

In this page you can find the example usage for org.apache.lucene.queryparser.flexible.standard.config FieldDateResolutionFCListener FieldDateResolutionFCListener.

Prototype

public FieldDateResolutionFCListener(QueryConfigHandler config) 

Source Link

Usage

From source file:com.sindicetech.siren.qparser.keyword.config.ExtendedKeywordQueryConfigHandler.java

License:Open Source License

public ExtendedKeywordQueryConfigHandler() {
    // Add listener that will build the FieldConfig attributes.
    // TODO: setting field configuration is to be deprecated once datatypes
    // in SIREn are correctly handled.
    this.addFieldConfigListener(new FieldDateResolutionFCListener(this));

    // Default Values
    this.set(ConfigurationKeys.ALLOW_LEADING_WILDCARD, false); // default in 2.9
    this.set(ConfigurationKeys.ANALYZER, null); //default value 2.4
    this.set(ConfigurationKeys.PHRASE_SLOP, 0); //default value 2.4
    this.set(ConfigurationKeys.LOWERCASE_EXPANDED_TERMS, false); // we should not lowercase expanded terms (#66)
    this.set(ConfigurationKeys.FIELD_BOOST_MAP, new LinkedHashMap<String, Float>());
    this.set(ConfigurationKeys.FUZZY_CONFIG, new FuzzyConfig());
    this.set(ConfigurationKeys.LOCALE, Locale.getDefault());
    this.set(ConfigurationKeys.FIELD_DATE_RESOLUTION_MAP, new HashMap<CharSequence, DateTools.Resolution>());

    // SIREn Default Values
    // This key is not used in SIREn. Instead, we use DATATYPES_ANALYZERS
    this.set(ConfigurationKeys.ANALYZER, null);
    // Set the primitive datatypes. Those are mandatory.
    final Map<String, Analyzer> datatypes = new HashMap<String, Analyzer>();
    datatypes.put(XSDDatatype.XSD_STRING, new StandardAnalyzer(Version.LUCENE_46));
    datatypes.put(JSONDatatype.JSON_FIELD, new WhitespaceAnalyzer(Version.LUCENE_46));
    this.set(KeywordConfigurationKeys.DATATYPES_ANALYZERS, datatypes);
    // The default datatype to assign if no datatype is defined
    this.set(KeywordConfigurationKeys.DEFAULT_DATATYPE, XSDDatatype.XSD_STRING);

    this.set(KeywordConfigurationKeys.ALLOW_TWIG, true);
    this.set(ConfigurationKeys.ENABLE_POSITION_INCREMENTS, true);
    this.set(KeywordConfigurationKeys.ALLOW_FUZZY_AND_WILDCARD, true);
    this.set(ConfigurationKeys.DEFAULT_OPERATOR, Operator.AND);
    this.set(KeywordConfigurationKeys.MULTI_NODE_TERM_REWRITE_METHOD,
            MultiNodeTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT);
    this.set(KeywordConfigurationKeys.ROOT_LEVEL, 1);
}