Mercurial Hosting > luan
diff lucene/src/luan/modules/lucene/LuceneDocument.java @ 544:c5a93767cc5c
lucene overhaul, untested
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 12 Jun 2015 19:11:44 -0600 |
parents | d9df6d6cb927 |
children |
line wrap: on
line diff
--- a/lucene/src/luan/modules/lucene/LuceneDocument.java Mon Jun 08 01:11:08 2015 -0400 +++ b/lucene/src/luan/modules/lucene/LuceneDocument.java Fri Jun 12 19:11:44 2015 -0600 @@ -21,12 +21,9 @@ public class LuceneDocument { - // I assume there will be more flags later - public static final String INDEX = "index"; - private LuceneDocument(String a) {} // never - static Document toLucene(LuanState luan,LuanTable table,Map<String,String> nameMap) throws LuanException { + static Document toLucene(LuanState luan,LuanTable table,Set<String> indexed) throws LuanException { Document doc = new Document(); for( Map.Entry<Object,Object> entry : table.iterable(luan) ) { Object key = entry.getKey(); @@ -34,38 +31,30 @@ throw luan.exception("key must be string"); String name = (String)key; Object value = entry.getValue(); - String newName = nameMap.get(name); - if( newName != null ) - name = newName; - Set<String> flags = new HashSet<String>(); - String[] a = name.split(" +"); - for( int i=1; i<a.length; i++ ) { - flags.add(a[i]); - } if( value instanceof String ) { String s = (String)value; - if( flags.remove(INDEX) ) { + if( indexed.contains(name) ) { doc.add(new StringField(name, s, Field.Store.YES)); } else { doc.add(new StoredField(name, s)); } } else if( value instanceof Integer ) { int i = (Integer)value; - if( flags.remove(INDEX) ) { + if( indexed.contains(name) ) { doc.add(new IntField(name, i, Field.Store.YES)); } else { doc.add(new StoredField(name, i)); } } else if( value instanceof Long ) { long i = (Long)value; - if( flags.remove(INDEX) ) { + if( indexed.contains(name) ) { doc.add(new LongField(name, i, Field.Store.YES)); } else { doc.add(new StoredField(name, i)); } } else if( value instanceof Double ) { double i = (Double)value; - if( flags.remove(INDEX) ) { + if( indexed.contains(name) ) { doc.add(new DoubleField(name, i, Field.Store.YES)); } else { doc.add(new StoredField(name, i)); @@ -75,21 +64,16 @@ doc.add(new StoredField(name, b)); } else throw luan.exception("invalid value type "+value.getClass()+"' for '"+name+"'"); - if( !flags.isEmpty() ) - throw luan.exception("invalid flags "+flags+" in '"+name+"'"); } return doc; } - static LuanTable toTable(LuanState luan,Document doc,Map<String,String> nameMap) throws LuanException { + static LuanTable toTable(LuanState luan,Document doc) throws LuanException { if( doc==null ) return null; LuanTable table = new LuanTable(); for( IndexableField ifld : doc ) { String name = ifld.name(); - String newName = nameMap.get(name); - if( newName != null ) - name = newName; BytesRef br = ifld.binaryValue(); if( br != null ) { table.rawPut(name,br.bytes);