r57937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57936‎ | r57937 | r57938 >
Date:00:10, 20 October 2009
Author:rainman
Status:deferred
Tags:
Comment:
Bug 21101 - fix did you mean trigger for fields prefixed with +
Modified paths:
  • /branches/lucene-search-2.1/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java (modified) (history)
  • /branches/lucene-search-2.1/test/org/wikimedia/lsearch/analyzers/WikiQueryParserTest.java (modified) (history)

Diff [purge]

Index: branches/lucene-search-2.1/test/org/wikimedia/lsearch/analyzers/WikiQueryParserTest.java
@@ -1,9 +1,11 @@
22 package org.wikimedia.lsearch.analyzers;
33
 4+import java.util.ArrayList;
45 import java.util.Arrays;
56 import java.util.HashSet;
67
78 import org.apache.lucene.analysis.Analyzer;
 9+import org.apache.lucene.analysis.Token;
810 import org.apache.lucene.search.Query;
911 import org.wikimedia.lsearch.analyzers.Analyzers;
1012 import org.wikimedia.lsearch.analyzers.FieldBuilder;
@@ -128,6 +130,12 @@
129131
130132 q = parser.parseRaw("something (intitle:[2]:tests) out");
131133 assertEquals("+contents:something +(title:tests title:test^0.5) +contents:out",q.toString());
 134+
 135+ ArrayList<Token> tokens = parser.tokenizeForSpellCheck("+incategory:\"zero\" a:b incategory:c +incategory:d [1]:20");
 136+ assertEquals("[(a,19,20), (b,21,22), (c,34,35), (d,48,49), (20,54,56)]", tokens.toString());
 137+
 138+ tokens = parser.tokenizeForSpellCheck("+incategory:\"Suspension bridges in the United States\"");
 139+ assertEquals("[]", tokens.toString());
132140
133141
134142 } catch(Exception e){
Index: branches/lucene-search-2.1/src/org/wikimedia/lsearch/analyzers/WikiQueryParser.java
@@ -540,9 +540,11 @@
541541 } else if(fieldLevel != -1 && level>fieldLevel)
542542 continue;
543543
544 - if(isTermChar(c) && text[cur]!='-'){
 544+ // include exclusion/inclusion marks
 545+ if(isTermChar(c) && text[cur]!='-' && text[cur]!='+'){
545546 int start = cur;
546547 tokenType = fetchToken(inPhrase);
 548+ // ignore excluded words
547549 if(tokenType == TokenType.WORD && (start==0 || text[start-1]!='-')){
548550 String type = "word";
549551 if(bufferIsWildCard())

Status & tagging log