comparison src/luan/modules/lucene/LuceneIndex.java @ 1529:e6d808f40bbc

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 27 Jul 2020 12:54:31 -0600
parents 3bd4d7963456
children 447b7ef9197f
comparison
equal deleted inserted replaced
1528:3bd4d7963456 1529:e6d808f40bbc
10 import java.sql.SQLException; 10 import java.sql.SQLException;
11 import java.util.Arrays; 11 import java.util.Arrays;
12 import java.util.Iterator; 12 import java.util.Iterator;
13 import java.util.Map; 13 import java.util.Map;
14 import java.util.HashMap; 14 import java.util.HashMap;
15 import java.util.LinkedHashMap;
16 import java.util.List; 15 import java.util.List;
17 import java.util.ArrayList; 16 import java.util.ArrayList;
18 import java.util.Set; 17 import java.util.Set;
19 import java.util.HashSet; 18 import java.util.HashSet;
20 import java.util.Collections; 19 import java.util.Collections;
577 } 576 }
578 mfp.fields.put( field, fp ); 577 mfp.fields.put( field, fp );
579 } 578 }
580 579
581 static Map<String,Object> toLucene(LuanTable table) throws LuanException { 580 static Map<String,Object> toLucene(LuanTable table) throws LuanException {
582 Map<String,Object> map = new LinkedHashMap<String,Object>(); 581 return SupplementingConfig.toLucene(table);
583 for( Map.Entry<Object,Object> entry : table.iterable() ) {
584 String name = (String)entry.getKey();
585 Object value = entry.getValue();
586 if( value instanceof LuanTable ) {
587 LuanTable list = (LuanTable)value;
588 if( !list.isList() )
589 throw new LuanException("table value for '"+name+"' must be a list");
590 value = list.asList();
591 }
592 map.put(name,value);
593 }
594 return map;
595 } 582 }
596 583
597 private static LuanTable toTable(Luan luan,Document doc) throws LuanException { 584 private static LuanTable toTable(Luan luan,Document doc) throws LuanException {
598 return doc==null ? null : toTable(luan,LuceneUtils.toMap(doc)); 585 return doc==null ? null : SupplementingConfig.toTable(luan,LuceneUtils.toMap(doc));
599 }
600
601 static LuanTable toTable(Luan luan,Map map) throws LuanException {
602 LuanTable table = new LuanTable(luan);
603 for( Object obj : map.entrySet() ) {
604 Map.Entry entry = (Map.Entry)obj;
605 Object value = entry.getValue();
606 if( value instanceof List )
607 value = new LuanTable(luan,(List)value);
608 table.rawPut( entry.getKey(), value );
609 }
610 return table;
611 } 586 }
612 587
613 588
614 private static final Formatter nullFormatter = new Formatter() { 589 private static final Formatter nullFormatter = new Formatter() {
615 public String highlightTerm(String originalText,TokenGroup tokenGroup) { 590 public String highlightTerm(String originalText,TokenGroup tokenGroup) {