Search in sources :

Example 1 with SimplePayloadFilter

use of org.apache.lucene.analysis.SimplePayloadFilter in project lucene-solr by apache.

the class TestPayloadCheckQuery method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    Analyzer simplePayloadAnalyzer = new Analyzer() {

        @Override
        public TokenStreamComponents createComponents(String fieldName) {
            Tokenizer tokenizer = new MockTokenizer(MockTokenizer.SIMPLE, true);
            return new TokenStreamComponents(tokenizer, new SimplePayloadFilter(tokenizer));
        }
    };
    directory = newDirectory();
    RandomIndexWriter writer = new RandomIndexWriter(random(), directory, newIndexWriterConfig(simplePayloadAnalyzer).setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000)).setMergePolicy(newLogMergePolicy()));
    //writer.infoStream = System.out;
    for (int i = 0; i < 2000; i++) {
        Document doc = new Document();
        doc.add(newTextField("field", English.intToEnglish(i), Field.Store.YES));
        writer.addDocument(doc);
    }
    reader = writer.getReader();
    searcher = newSearcher(reader);
    writer.close();
}
Also used : MockTokenizer(org.apache.lucene.analysis.MockTokenizer) Analyzer(org.apache.lucene.analysis.Analyzer) Document(org.apache.lucene.document.Document) Tokenizer(org.apache.lucene.analysis.Tokenizer) MockTokenizer(org.apache.lucene.analysis.MockTokenizer) SimplePayloadFilter(org.apache.lucene.analysis.SimplePayloadFilter) RandomIndexWriter(org.apache.lucene.index.RandomIndexWriter) BeforeClass(org.junit.BeforeClass)

Aggregations

Analyzer (org.apache.lucene.analysis.Analyzer)1 MockTokenizer (org.apache.lucene.analysis.MockTokenizer)1 SimplePayloadFilter (org.apache.lucene.analysis.SimplePayloadFilter)1 Tokenizer (org.apache.lucene.analysis.Tokenizer)1 Document (org.apache.lucene.document.Document)1 RandomIndexWriter (org.apache.lucene.index.RandomIndexWriter)1 BeforeClass (org.junit.BeforeClass)1