/**
 * 
 */
package de.bstly.board;

import org.apache.lucene.analysis.core.LowerCaseFilterFactory;
import org.apache.lucene.analysis.core.WhitespaceTokenizerFactory;
import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilterFactory;
import org.apache.lucene.analysis.ngram.EdgeNGramFilterFactory;
import org.apache.lucene.analysis.snowball.SnowballPorterFilterFactory;
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurationContext;
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurer;
import org.springframework.context.annotation.Configuration;

/**
 * @author _bastler@bstly.de
 *
 */
@Configuration
public class LuceneConfig implements LuceneAnalysisConfigurer {

	/*
	 * @see org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurer#
	 * configure(org.hibernate.search.backend.lucene.analysis.
	 * LuceneAnalysisConfigurationContext)
	 */
	@Override
	public void configure(LuceneAnalysisConfigurationContext context) {
		context.analyzer("english").custom().tokenizer(WhitespaceTokenizerFactory.class)
				.tokenFilter(LowerCaseFilterFactory.class)
				.tokenFilter(SnowballPorterFilterFactory.class).param("language", "English")
				.tokenFilter(ASCIIFoldingFilterFactory.class)
				.tokenFilter(EdgeNGramFilterFactory.class).param("minGramSize", "1")
				.param("maxGramSize", "10");

		context.analyzer("german").custom().tokenizer(WhitespaceTokenizerFactory.class)
				.tokenFilter(LowerCaseFilterFactory.class)
				.tokenFilter(SnowballPorterFilterFactory.class).param("language", "German")
				.tokenFilter(ASCIIFoldingFilterFactory.class)
				.tokenFilter(EdgeNGramFilterFactory.class).param("minGramSize", "1")
				.param("maxGramSize", "10");

	}

}
