diff src/goodjava/lucene/api/LuceneUtils.java @ 1771:c62324841dfb

improve NumberFieldParser and add key map lucene query
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 25 Jun 2023 15:05:09 -0600
parents e5d48b85351c
children
line wrap: on
line diff
--- a/src/goodjava/lucene/api/LuceneUtils.java	Thu Jun 15 17:55:47 2023 -0600
+++ b/src/goodjava/lucene/api/LuceneUtils.java	Sun Jun 25 15:05:09 2023 -0600
@@ -8,7 +8,7 @@
 import org.apache.lucene.index.IndexableField;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.NumericUtils;
+import goodjava.lucene.queryparser.NumberFieldParser;
 
 
 public final class LuceneUtils {
@@ -56,13 +56,9 @@
 		if( value instanceof String ) {
 			return new Term(name,(String)value);
 		} else if( value instanceof Long ) {
-			BytesRef br = new BytesRef();
-			NumericUtils.longToPrefixCoded((Long)value,0,br);
-			return new Term(name,br);
+			return NumberFieldParser.term(name,(Long)value);
 		} else if( value instanceof Integer ) {
-			BytesRef br = new BytesRef();
-			NumericUtils.intToPrefixCoded((Integer)value,0,br);
-			return new Term(name,br);
+			return NumberFieldParser.term(name,(Integer)value);
 		} else
 			throw new RuntimeException("invalid value type "+value.getClass()+"' for term '"+name+"'");
 	}