annotate src/goodjava/lucene/api/MultiFieldParserConfig.java @ 1516:70a55f49b98e

digest_message
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 08 Jun 2020 21:54:31 -0600
parents 3ab0d043370f
children f848d40b3b07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 package goodjava.lucene.api;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 import java.util.Map;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 import java.util.Collections;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 import org.apache.lucene.analysis.Analyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 import org.apache.lucene.analysis.core.KeywordAnalyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 import goodjava.lucene.queryparser.MultiFieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 import goodjava.lucene.queryparser.FieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 import goodjava.lucene.queryparser.StringFieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 public class MultiFieldParserConfig implements GoodIndexWriterConfig {
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 private final MultiFieldParser mfp;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 public MultiFieldParserConfig(MultiFieldParser mfp) {
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 this.mfp = mfp;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 public final boolean isIndexed(String fieldName) {
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 return mfp.fields.containsKey(fieldName);
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 public final Analyzer getAnalyzer(String fieldName) {
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 FieldParser fp = mfp.fields.get(fieldName);
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 if( !(fp instanceof StringFieldParser) )
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 return null;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 StringFieldParser sfp = (StringFieldParser)fp;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 Analyzer analyzer = sfp.analyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 return analyzer instanceof KeywordAnalyzer ? null : analyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 public Map<String,Object> getUnstoredFields(Map<String,Object> storedFields) {
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 return Collections.emptyMap();
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 }