comparison src/luan/modules/lucene/queryparser/StringFieldParser.java @ 1110:38a42f437fd2

queryparser now uses parsers.Parser
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 02 Aug 2017 13:45:06 -0600
parents 1a68fc55a80c
children 88b5b81cad4a
comparison
equal deleted inserted replaced
1109:8c999ab85e33 1110:38a42f437fd2
12 import org.apache.lucene.search.PhraseQuery; 12 import org.apache.lucene.search.PhraseQuery;
13 import org.apache.lucene.search.WildcardQuery; 13 import org.apache.lucene.search.WildcardQuery;
14 import org.apache.lucene.search.PrefixQuery; 14 import org.apache.lucene.search.PrefixQuery;
15 import org.apache.lucene.search.SortField; 15 import org.apache.lucene.search.SortField;
16 import org.apache.lucene.index.Term; 16 import org.apache.lucene.index.Term;
17 import luan.modules.parsers.ParseException;
17 18
18 19
19 public class StringFieldParser implements FieldParser { 20 public class StringFieldParser implements FieldParser {
20 public int slop = 0; 21 public int slop = 0;
21 public final Analyzer analyzer; 22 public final Analyzer analyzer;
73 StringBuilder sb = new StringBuilder(); 74 StringBuilder sb = new StringBuilder();
74 for( ; i<n; i++ ) { 75 for( ; i<n; i++ ) {
75 char c = a[i]; 76 char c = a[i];
76 if( c == '\\' ) { 77 if( c == '\\' ) {
77 if( ++i == a.length ) 78 if( ++i == a.length )
78 throw new ParseException(qp,"ends with '\\'"); 79 throw qp.exception("ends with '\\'");
79 c = a[i]; 80 c = a[i];
80 } 81 }
81 sb.append(c); 82 sb.append(c);
82 } 83 }
83 return sb.toString(); 84 return sb.toString();
93 char c = a[i]; 94 char c = a[i];
94 if( c=='?' || c=='*' && i<a.length-1 ) 95 if( c=='?' || c=='*' && i<a.length-1 )
95 hasWildcard = true; 96 hasWildcard = true;
96 if( c == '\\' ) { 97 if( c == '\\' ) {
97 if( ++i == a.length ) 98 if( ++i == a.length )
98 throw new ParseException(qp,"ends with '\\'"); 99 throw qp.exception("ends with '\\'");
99 c = a[i]; 100 c = a[i];
100 if( c=='?' || c=='*' ) 101 if( c=='?' || c=='*' )
101 sb.append('\\'); 102 sb.append('\\');
102 } 103 }
103 sb.append(c); 104 sb.append(c);