lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tflo...@apache.org
Subject [13/24] lucene-solr:jira/solr-8396: LUCENE-7490: SimpleQueryParser now parses '*' as MatchAllDocsQuery
Date Sat, 15 Oct 2016 23:55:25 GMT
LUCENE-7490: SimpleQueryParser now parses '*' as MatchAllDocsQuery


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/4ae1643f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/4ae1643f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/4ae1643f

Branch: refs/heads/jira/solr-8396
Commit: 4ae1643f66bb2d90b04b1dd7c12c55d9c24bcd33
Parents: 175370f
Author: Mike McCandless <mikemccand@apache.org>
Authored: Wed Oct 12 13:30:22 2016 -0400
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Wed Oct 12 13:30:22 2016 -0400

----------------------------------------------------------------------
 lucene/CHANGES.txt                                            | 3 +++
 .../apache/lucene/queryparser/simple/SimpleQueryParser.java   | 4 ++++
 .../lucene/queryparser/simple/TestSimpleQueryParser.java      | 7 +++++++
 3 files changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4ae1643f/lucene/CHANGES.txt
----------------------------------------------------------------------
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index f076be5..1981c52 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -53,6 +53,9 @@ New Features
   in postings for fast wildcard (MultiTermQuery) highlighting.
   (David Smiley, Timothy Rodriguez)
 
+* LUCENE-7490: SimpleQueryParser now parses '*' to MatchAllDocsQuery
+  (Lee Hinman via Mike McCandless)
+
 Bug Fixes
 
 * LUCENE-7472: MultiFieldQueryParser.getFieldQuery() drops queries that are

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4ae1643f/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
b/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
index a417d1b..6e05aec 100644
--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/simple/SimpleQueryParser.java
@@ -145,6 +145,10 @@ public class SimpleQueryParser extends QueryBuilder {
 
   /** Parses the query text and returns parsed query */
   public Query parse(String queryText) {
+    if ("*".equals(queryText.trim())) {
+      return new MatchAllDocsQuery();
+    }
+
     char data[] = queryText.toCharArray();
     char buffer[] = new char[data.length];
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4ae1643f/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
----------------------------------------------------------------------
diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
b/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
index a8e2327..d70a22c 100644
--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
@@ -623,4 +623,11 @@ public class TestSimpleQueryParser extends LuceneTestCase {
       parseKeyword(sb.toString(), TestUtil.nextInt(random(), 0, 1024)); // no exception
     }
   }
+
+  public void testStarBecomesMatchAll() throws Exception {
+    Query q = parse("*");
+    assertEquals(q, new MatchAllDocsQuery());
+    q = parse(" *   ");
+    assertEquals(q, new MatchAllDocsQuery());
+  }
 }


Mime
View raw message