Changeset 12387
- Timestamp:
- 2006-08-02T17:21:57+12:00 (18 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/java/org/nzdl/gsdl/LuceneWrap/GS2LuceneQuery.java
r12377 r12387 89 89 ///ystem.err.println("**** query = " + query_string); 90 90 91 Query query = query_parser.parse(query_string);92 query = query.rewrite(reader);93 91 Query query_including_stop_words = query_parser_no_stop_words.parse(query_string); 94 92 query_including_stop_words = query_including_stop_words.rewrite(reader); 93 94 // Split query string into the search terms and the filter terms 95 // * The first +(...) term contains the search terms so count 96 // up '(' and stop when we finish matching ')' 97 int offset = 0; 98 int paren_count = 0; 99 boolean seen_paren = false; 100 while (offset < query_string.length() && (!seen_paren || paren_count > 0)) 101 { 102 if (query_string.charAt(offset) == '(') 103 { 104 paren_count++; 105 seen_paren = true; 106 } 107 if (query_string.charAt(offset) == ')') 108 { 109 paren_count--; 110 } 111 offset++; 112 } 113 String query_prefix = query_string.substring(0, offset); 114 String query_suffix = query_string.substring(offset); 115 116 ///ystem.err.println("Prefix: " + query_prefix); 117 ///ystem.err.println("Suffix: " + query_suffix); 118 119 Query query = query_parser.parse(query_prefix); 120 query = query.rewrite(reader); 95 121 96 122 // If this is a fuzzy search, then we need to add the fuzzy … … 112 138 { 113 139 char c = mutable_query_string.charAt(o); 114 ///ystem.err.println("SM: in state " + s + " and reading a " + c);115 140 if (s == 0 && c == 'T') 116 141 { … … 153 178 // fuzzy search indicator 154 179 // Nor outside the scope of parentheses 155 if (Character.isWhitespace(c) || c == ')')180 else if (Character.isWhitespace(c) || c == ')') 156 181 { 157 182 ///ystem.err.println("Yahoo! Found fuzzy term."); … … 170 195 } 171 196 // Reparse the query 172 ///ystem.err.println("Fuzzy query: " + mutable_query_string.toString() );173 query = query_parser.parse(mutable_query_string.toString() );197 ///ystem.err.println("Fuzzy query: " + mutable_query_string.toString() + query_suffix); 198 query = query_parser.parse(mutable_query_string.toString() + query_suffix); 174 199 // And rewrite again 175 200 query = query.rewrite(reader); -
trunk/indexers/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java
r12377 r12387 89 89 ///ystem.err.println("**** query = " + query_string); 90 90 91 Query query = query_parser.parse(query_string);92 query = query.rewrite(reader);93 91 Query query_including_stop_words = query_parser_no_stop_words.parse(query_string); 94 92 query_including_stop_words = query_including_stop_words.rewrite(reader); 93 94 // Split query string into the search terms and the filter terms 95 // * The first +(...) term contains the search terms so count 96 // up '(' and stop when we finish matching ')' 97 int offset = 0; 98 int paren_count = 0; 99 boolean seen_paren = false; 100 while (offset < query_string.length() && (!seen_paren || paren_count > 0)) 101 { 102 if (query_string.charAt(offset) == '(') 103 { 104 paren_count++; 105 seen_paren = true; 106 } 107 if (query_string.charAt(offset) == ')') 108 { 109 paren_count--; 110 } 111 offset++; 112 } 113 String query_prefix = query_string.substring(0, offset); 114 String query_suffix = query_string.substring(offset); 115 116 ///ystem.err.println("Prefix: " + query_prefix); 117 ///ystem.err.println("Suffix: " + query_suffix); 118 119 Query query = query_parser.parse(query_prefix); 120 query = query.rewrite(reader); 95 121 96 122 // If this is a fuzzy search, then we need to add the fuzzy … … 112 138 { 113 139 char c = mutable_query_string.charAt(o); 114 ///ystem.err.println("SM: in state " + s + " and reading a " + c);115 140 if (s == 0 && c == 'T') 116 141 { … … 153 178 // fuzzy search indicator 154 179 // Nor outside the scope of parentheses 155 if (Character.isWhitespace(c) || c == ')')180 else if (Character.isWhitespace(c) || c == ')') 156 181 { 157 182 ///ystem.err.println("Yahoo! Found fuzzy term."); … … 170 195 } 171 196 // Reparse the query 172 ///ystem.err.println("Fuzzy query: " + mutable_query_string.toString() );173 query = query_parser.parse(mutable_query_string.toString() );197 ///ystem.err.println("Fuzzy query: " + mutable_query_string.toString() + query_suffix); 198 query = query_parser.parse(mutable_query_string.toString() + query_suffix); 174 199 // And rewrite again 175 200 query = query.rewrite(reader);
Note:
See TracChangeset
for help on using the changeset viewer.