view src/goodjava/lucene/api/MultiFieldParserConfig.java @ 1497:f04bfbb08721

link_from
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 08 May 2020 16:54:30 -0600
parents 3ab0d043370f
children f848d40b3b07
line wrap: on
line source

package goodjava.lucene.api;

import java.util.Map;
import java.util.Collections;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.core.KeywordAnalyzer;
import goodjava.lucene.queryparser.MultiFieldParser;
import goodjava.lucene.queryparser.FieldParser;
import goodjava.lucene.queryparser.StringFieldParser;


public class MultiFieldParserConfig implements GoodIndexWriterConfig {
	private final MultiFieldParser mfp;

	public MultiFieldParserConfig(MultiFieldParser mfp) {
		this.mfp = mfp;
	}

	public final boolean isIndexed(String fieldName) {
		return mfp.fields.containsKey(fieldName);
	}

	public final Analyzer getAnalyzer(String fieldName) {
		FieldParser fp = mfp.fields.get(fieldName);
		if( !(fp instanceof StringFieldParser) )
			return null;
		StringFieldParser sfp = (StringFieldParser)fp;
		Analyzer analyzer = sfp.analyzer;
		return analyzer instanceof KeywordAnalyzer ? null : analyzer;
	}

	public Map<String,Object> getUnstoredFields(Map<String,Object> storedFields) {
		return Collections.emptyMap();
	}
}