lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r826013 - in /lucene/java/trunk: ./ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/document/ src/test/org/apache/lucene/index/ src/test/org/apache/lucene/search/
Date Fri, 16 Oct 2009 17:37:16 GMT
Author: mikemccand
Date: Fri Oct 16 17:37:16 2009
New Revision: 826013

URL: http://svn.apache.org/viewvc?rev=826013&view=rev
Log:
LUCENE-1124: make sure FuzzyQuery matches the exact term

Modified:
    lucene/java/trunk/   (props changed)
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java 
 (props changed)
    lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java   (props changed)
    lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java   (props changed)
    lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java   (props
changed)
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java

Propchange: lucene/java/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 16 17:37:16 2009
@@ -1,3 +1,3 @@
 /lucene/java/branches/lucene_2_4:748824
-/lucene/java/branches/lucene_2_9:817269-818600
+/lucene/java/branches/lucene_2_9:817269-818600,825998
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=826013&r1=826012&r2=826013&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Fri Oct 16 17:37:16 2009
@@ -87,6 +87,9 @@
   BooleanScorer for scoring), whereby some matching documents fail to
   be collected.  (Fulin Tang via Mike McCandless)
 
+* LUCENE-1124: Make sure FuzzyQuery always matches the precise term.
+  (stefatwork@gmail.com via Mike McCandless)
+
 New features
 
 * LUCENE-1933: Provide a convenience AttributeFactory that creates a

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java?rev=826013&r1=826012&r2=826013&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FuzzyQuery.java Fri Oct 16 17:37:16
2009
@@ -126,8 +126,8 @@
   
   @Override
   public Query rewrite(IndexReader reader) throws IOException {
-    if(!termLongEnough) {  // can't match
-      return new BooleanQuery();
+    if(!termLongEnough) {  // can only match if it's exact
+      return new TermQuery(term);
     }
 
     FilteredTermEnum enumerator = getEnum(reader);

Propchange: lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 16 17:37:16 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
+/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998

Propchange: lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 16 17:37:16 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
+/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998

Propchange: lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 16 17:37:16 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
+/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998

Propchange: lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 16 17:37:16 2009
@@ -1 +1,2 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
+/lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java?rev=826013&r1=826012&r2=826013&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java Fri Oct 16 17:37:16
2009
@@ -19,13 +19,18 @@
 
 import java.io.IOException;
 
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.queryParser.QueryParser;
 
 /**
  * Tests {@link FuzzyQuery}.
@@ -281,6 +286,43 @@
     assertEquals(0, hits.length);
   }
   
+  public void testGiga() throws Exception {
+
+    StandardAnalyzer analyzer = new StandardAnalyzer();
+
+    Directory index = new MockRAMDirectory();
+    IndexWriter w = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
+
+    addDoc("Lucene in Action", w);
+    addDoc("Lucene for Dummies", w);
+
+    //addDoc("Giga", w);
+    addDoc("Giga byte", w);
+
+    addDoc("ManagingGigabytesManagingGigabyte", w);
+    addDoc("ManagingGigabytesManagingGigabytes", w);
+
+    addDoc("The Art of Computer Science", w);
+    addDoc("J. K. Rowling", w);
+    addDoc("JK Rowling", w);
+    addDoc("Joanne K Roling", w);
+    addDoc("Bruce Willis", w);
+    addDoc("Willis bruce", w);
+    addDoc("Brute willis", w);
+    addDoc("B. willis", w);
+    IndexReader r = w.getReader();
+    w.close();
+
+    Query q = new QueryParser("field", analyzer).parse( "giga~0.9" );
+
+    // 3. search
+    IndexSearcher searcher = new IndexSearcher(r);
+    ScoreDoc[] hits = searcher.search(q, 10).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals("Giga byte", searcher.doc(hits[0].doc).get("field"));
+    r.close();
+  }
+
   private void addDoc(String text, IndexWriter writer) throws IOException {
     Document doc = new Document();
     doc.add(new Field("field", text, Field.Store.YES, Field.Index.ANALYZED));



Mime
View raw message