Mercurial Hosting > luan
annotate src/goodjava/lucene/api/MultiFieldParserConfig.java @ 1707:ad5647031343
fix blog
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 04 Jul 2022 12:40:59 -0600 |
parents | f48db13ae2d9 |
children |
rev | line source |
---|---|
1460 | 1 package goodjava.lucene.api; |
2 | |
3 import java.util.Map; | |
4 import java.util.Collections; | |
5 import org.apache.lucene.analysis.Analyzer; | |
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 | 9 import goodjava.lucene.queryparser.MultiFieldParser; |
10 import goodjava.lucene.queryparser.FieldParser; | |
11 import goodjava.lucene.queryparser.StringFieldParser; | |
12 | |
13 | |
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 | 16 private final MultiFieldParser mfp; |
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 | 20 this.mfp = mfp; |
21 } | |
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 | 28 return mfp.fields.containsKey(fieldName); |
29 } | |
30 | |
1687
f48db13ae2d9
unlogged lucene support
Franklin Schmidt <fschmidt@gmail.com>
parents:
1528
diff
changeset
|
31 @Override public final Analyzer getAnalyzer(String fieldName) { |
1460 | 32 FieldParser fp = mfp.fields.get(fieldName); |
33 if( !(fp instanceof StringFieldParser) ) | |
34 return null; | |
35 StringFieldParser sfp = (StringFieldParser)fp; | |
36 Analyzer analyzer = sfp.analyzer; | |
37 return analyzer instanceof KeywordAnalyzer ? null : analyzer; | |
38 } | |
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 | 44 } |
45 } |