annotate src/goodjava/lucene/api/MultiFieldParserConfig.java @ 1831:8f9ae295bf6a default tip

add Hosted.authorize
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 26 Sep 2024 15:07:45 -0600
parents f48db13ae2d9
children
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;
1528
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
7 import org.apache.lucene.index.IndexWriterConfig;
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
8 import org.apache.lucene.util.Version;
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 import goodjava.lucene.queryparser.MultiFieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 import goodjava.lucene.queryparser.FieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 import goodjava.lucene.queryparser.StringFieldParser;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 public class MultiFieldParserConfig implements GoodIndexWriterConfig {
1528
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
15 private final Version luceneVersion;
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 private final MultiFieldParser mfp;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
1528
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
18 public MultiFieldParserConfig(Version luceneVersion,MultiFieldParser mfp) {
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
19 this.luceneVersion = luceneVersion;
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 this.mfp = mfp;
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
1687
f48db13ae2d9 unlogged lucene support
Franklin Schmidt <fschmidt@gmail.com>
parents: 1528
diff changeset
23 @Override public IndexWriterConfig newLuceneConfig() {
1528
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
24 return new IndexWriterConfig(luceneVersion,new FieldAnalyzer());
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
25 }
3bd4d7963456 use goodjava/lucene/api
Franklin Schmidt <fschmidt@gmail.com>
parents: 1525
diff changeset
26
1687
f48db13ae2d9 unlogged lucene support
Franklin Schmidt <fschmidt@gmail.com>
parents: 1528
diff changeset
27 @Override public final boolean isIndexed(String fieldName) {
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 return mfp.fields.containsKey(fieldName);
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30
1687
f48db13ae2d9 unlogged lucene support
Franklin Schmidt <fschmidt@gmail.com>
parents: 1528
diff changeset
31 @Override public final Analyzer getAnalyzer(String fieldName) {
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 FieldParser fp = mfp.fields.get(fieldName);
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 if( !(fp instanceof StringFieldParser) )
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 return null;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 StringFieldParser sfp = (StringFieldParser)fp;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 Analyzer analyzer = sfp.analyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 return analyzer instanceof KeywordAnalyzer ? null : analyzer;
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39
1525
f848d40b3b07 lucene.api add boosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 1460
diff changeset
40 private static final MoreFieldInfo noMoreFieldInfo = new MoreFieldInfo(Collections.emptyMap(),Collections.emptyMap());
f848d40b3b07 lucene.api add boosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 1460
diff changeset
41
1687
f48db13ae2d9 unlogged lucene support
Franklin Schmidt <fschmidt@gmail.com>
parents: 1528
diff changeset
42 @Override public MoreFieldInfo getMoreFieldInfo(Map<String,Object> storedFields) {
1525
f848d40b3b07 lucene.api add boosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 1460
diff changeset
43 return noMoreFieldInfo;
1460
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 }
3ab0d043370f start lucene.api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 }