Package gov.nysenate.openleg.lucene

Source Code of gov.nysenate.openleg.lucene.OpenLegislationQueryParser

package gov.nysenate.openleg.lucene;

import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Map;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser;
import org.apache.lucene.queryparser.flexible.standard.config.NumericConfig;

public class OpenLegislationQueryParser extends StandardQueryParser
{
    public OpenLegislationQueryParser(Analyzer analyzer)
    {
        super(analyzer);

        // All fields indexed numerically need to be listed here in order to properly search on them.
        Map<String, NumericConfig> numericConfigMap = new HashMap<String, NumericConfig>();
        numericConfigMap.put("year", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.INT));
        numericConfigMap.put("modified", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        numericConfigMap.put("published", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        numericConfigMap.put("when", new NumericConfig(8, NumberFormat.getInstance(), FieldType.NumericType.LONG));
        this.setNumericConfigMap(numericConfigMap);
    }
}
TOP

Related Classes of gov.nysenate.openleg.lucene.OpenLegislationQueryParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.