comparison src/goodjava/lucene/queryparser/NumberFieldParser.java @ 1459:b04b8fc5f4f4

GoodQueryParser
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 20 Mar 2020 11:06:53 -0600
parents 6b6c11c9164e
children c62324841dfb
comparison
equal deleted inserted replaced
1458:6b6c11c9164e 1459:b04b8fc5f4f4
8 import goodjava.parser.ParseException; 8 import goodjava.parser.ParseException;
9 9
10 10
11 public abstract class NumberFieldParser implements FieldParser { 11 public abstract class NumberFieldParser implements FieldParser {
12 12
13 @Override public final Query getQuery(SaneQueryParser qp,String field,String query) throws ParseException { 13 @Override public final Query getQuery(GoodQueryParser qp,String field,String query) throws ParseException {
14 if( query.equals("*") ) 14 if( query.equals("*") )
15 return new PrefixQuery(new Term(field,"")); 15 return new PrefixQuery(new Term(field,""));
16 return getRangeQuery(qp,field,query,query,true,true); 16 return getRangeQuery(qp,field,query,query,true,true);
17 } 17 }
18 18
19 @Override public final Query getRangeQuery(SaneQueryParser qp,String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax) throws ParseException { 19 @Override public final Query getRangeQuery(GoodQueryParser qp,String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax) throws ParseException {
20 try { 20 try {
21 return getRangeQuery(field,minQuery,maxQuery,includeMin,includeMax); 21 return getRangeQuery(field,minQuery,maxQuery,includeMin,includeMax);
22 } catch(NumberFormatException e) { 22 } catch(NumberFormatException e) {
23 throw qp.exception(e); 23 throw qp.exception(e);
24 } 24 }
25 } 25 }
26 26
27 abstract protected Query getRangeQuery(String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax); 27 abstract protected Query getRangeQuery(String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax);
28 28
29 @Override public SortField getSortField(SaneQueryParser qp,String field,boolean reverse) { 29 @Override public SortField getSortField(GoodQueryParser qp,String field,boolean reverse) {
30 return new SortField( field, sortType(), reverse ); 30 return new SortField( field, sortType(), reverse );
31 } 31 }
32 32
33 abstract protected SortField.Type sortType(); 33 abstract protected SortField.Type sortType();
34 34