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

GoodQueryParser
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 20 Mar 2020 11:06:53 -0600
parents 6b6c11c9164e
children c6b50b7b958c
comparison
equal deleted inserted replaced
1458:6b6c11c9164e 1459:b04b8fc5f4f4
30 for( String field : defaultFields ) { 30 for( String field : defaultFields ) {
31 fields.put(field,defaultFieldParser); 31 fields.put(field,defaultFieldParser);
32 } 32 }
33 } 33 }
34 34
35 @Override public Query getQuery(SaneQueryParser qp,String field,String query) throws ParseException { 35 @Override public Query getQuery(GoodQueryParser qp,String field,String query) throws ParseException {
36 if( field == null ) { 36 if( field == null ) {
37 if( defaultFieldParser == null ) 37 if( defaultFieldParser == null )
38 throw qp.exception("no defaults were specified, so a field is required"); 38 throw qp.exception("no defaults were specified, so a field is required");
39 if( defaultFields.length == 1 ) 39 if( defaultFields.length == 1 )
40 return defaultFieldParser.getQuery(qp,defaultFields[0],query); 40 return defaultFieldParser.getQuery(qp,defaultFields[0],query);
51 return defaultFieldParser.getQuery(qp,field,query); 51 return defaultFieldParser.getQuery(qp,field,query);
52 throw qp.exception("unrecognized field '"+field+"'"); 52 throw qp.exception("unrecognized field '"+field+"'");
53 } 53 }
54 } 54 }
55 55
56 @Override public Query getRangeQuery(SaneQueryParser qp,String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax) throws ParseException { 56 @Override public Query getRangeQuery(GoodQueryParser qp,String field,String minQuery,String maxQuery,boolean includeMin,boolean includeMax) throws ParseException {
57 if( field == null ) { 57 if( field == null ) {
58 if( defaultFieldParser == null ) 58 if( defaultFieldParser == null )
59 throw qp.exception("no defaults were specified, so a field is required"); 59 throw qp.exception("no defaults were specified, so a field is required");
60 if( defaultFields.length == 1 ) 60 if( defaultFields.length == 1 )
61 return defaultFieldParser.getRangeQuery(qp,defaultFields[0],minQuery,maxQuery,includeMin,includeMax); 61 return defaultFieldParser.getRangeQuery(qp,defaultFields[0],minQuery,maxQuery,includeMin,includeMax);
72 return defaultFieldParser.getRangeQuery(qp,field,minQuery,maxQuery,includeMin,includeMax); 72 return defaultFieldParser.getRangeQuery(qp,field,minQuery,maxQuery,includeMin,includeMax);
73 throw qp.exception("field '"+field+"' not specified"); 73 throw qp.exception("field '"+field+"' not specified");
74 } 74 }
75 } 75 }
76 76
77 @Override public SortField getSortField(SaneQueryParser qp,String field,boolean reverse) throws ParseException { 77 @Override public SortField getSortField(GoodQueryParser qp,String field,boolean reverse) throws ParseException {
78 FieldParser fp = fields.get(field); 78 FieldParser fp = fields.get(field);
79 if( fp != null ) 79 if( fp != null )
80 return fp.getSortField(qp,field,reverse); 80 return fp.getSortField(qp,field,reverse);
81 if( allowUnspecifiedFields ) 81 if( allowUnspecifiedFields )
82 return defaultFieldParser.getSortField(qp,field,reverse); 82 return defaultFieldParser.getSortField(qp,field,reverse);