geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [07/50] [abbrv] geode git commit: GEODE-3291: add soundex analyzer into lucene query This closes #654
Date Tue, 01 Aug 2017 21:03:01 GMT
GEODE-3291: add soundex analyzer into lucene query
This closes #654


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

Branch: refs/heads/feature/GEODE-3299
Commit: 289a0857f5822aee89d78625d226d5765fac8d40
Parents: eb7d2ea
Author: zhouxh <gzhou@pivotal.io>
Authored: Mon Jul 24 14:27:42 2017 -0700
Committer: zhouxh <gzhou@pivotal.io>
Committed: Tue Jul 25 22:28:38 2017 -0700

----------------------------------------------------------------------
 geode-assembly/build.gradle                     |  1 +
 .../src/test/resources/expected_jars.txt        |  1 +
 geode-lucene/build.gradle                       |  1 +
 .../lucene/LuceneQueriesIntegrationTest.java    | 36 ++++++++++++++++++++
 4 files changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/289a0857/geode-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index 02c9e33..69f1f19 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -195,6 +195,7 @@ def cp = {
         it.contains('lucene-core') ||
         it.contains('lucene-queries') ||
         it.contains('lucene-queryparser') ||
+        it.contains('lucene-analyzers-phonetic') ||
 
         // dependencies from geode-protobuf
         it.contains('protobuf-java')

http://git-wip-us.apache.org/repos/asf/geode/blob/289a0857/geode-assembly/src/test/resources/expected_jars.txt
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/resources/expected_jars.txt b/geode-assembly/src/test/resources/expected_jars.txt
index 05f5834..a082539 100644
--- a/geode-assembly/src/test/resources/expected_jars.txt
+++ b/geode-assembly/src/test/resources/expected_jars.txt
@@ -46,6 +46,7 @@ lucene-analyzers-common
 lucene-core
 lucene-queries
 lucene-queryparser
+lucene-analyzers-phonetic
 mx4j
 mx4j-remote
 mx4j-tools

http://git-wip-us.apache.org/repos/asf/geode/blob/289a0857/geode-lucene/build.gradle
----------------------------------------------------------------------
diff --git a/geode-lucene/build.gradle b/geode-lucene/build.gradle
index 74de7a6..66061aa 100644
--- a/geode-lucene/build.gradle
+++ b/geode-lucene/build.gradle
@@ -22,6 +22,7 @@ dependencies {
     compile 'org.apache.lucene:lucene-analyzers-common:' + project.'lucene.version'
     compile 'org.apache.lucene:lucene-core:' + project.'lucene.version'
     compile 'org.apache.lucene:lucene-queries:' + project.'lucene.version'
+    compile ('org.apache.lucene:lucene-analyzers-phonetic:' + project.'lucene.version')
     compile ('org.apache.lucene:lucene-queryparser:' + project.'lucene.version') {
       exclude module: 'lucene-sandbox'
     }

http://git-wip-us.apache.org/repos/asf/geode/blob/289a0857/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
index 3c0b10d..fb86e19 100644
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneQueriesIntegrationTest.java
@@ -145,6 +145,42 @@ public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest
{
         "primitiveInt2");
   }
 
+  @Test()
+  public void shouldQueryUsingSoundexAnalyzer() throws Exception {
+    Map<String, Analyzer> fields = new HashMap<String, Analyzer>();
+    fields.put("field1", new StandardAnalyzer());
+    fields.put("field2", new DoubleMetaphoneAnalyzer());
+    luceneService.createIndexFactory().setFields(fields).create(INDEX_NAME, REGION_NAME);
+    Region region = cache.createRegionFactory(RegionShortcut.PARTITION).create(REGION_NAME);
+    final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
+
+    // Put two values with some of the same tokens
+    String value1 = "Stefan";
+    String value2 = "Steph";
+    String value3 = "Stephen";
+    String value4 = "Steve";
+    String value5 = "Steven";
+    String value6 = "Stove";
+    String value7 = "Stuffin";
+
+    region.put("A", new TestObject(value1, value1));
+    region.put("B", new TestObject(value2, value2));
+    region.put("C", new TestObject(value3, value3));
+    region.put("D", new TestObject(value4, value4));
+    region.put("E", new TestObject(value5, value5));
+    region.put("F", new TestObject(value6, value6));
+    region.put("G", new TestObject(value7, value7));
+
+    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, 60000, TimeUnit.MILLISECONDS);
+    // soundex search
+    verifyQuery("field2:Stephen", DEFAULT_FIELD, "A", "C", "E", "G");
+
+    // compare with Ste* search on soundex analyzer will not find anything
+    // but on standard analyzer will find 5 matchs
+    verifyQuery("field2:Ste*", DEFAULT_FIELD);
+    verifyQuery("field1:Ste*", DEFAULT_FIELD, "A", "B", "C", "D", "E");
+  }
+
   @Ignore
   @Test()
   public void queryParserCannotQueryByRange() throws Exception {


Mime
View raw message