geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zho...@apache.org
Subject geode git commit: GEODE-11: add unit test for soundex analyzer
Date Thu, 11 May 2017 18:33:59 GMT
Repository: geode
Updated Branches:
  refs/heads/develop ab7e51f82 -> c8f337c08


GEODE-11: add unit test for soundex analyzer


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

Branch: refs/heads/develop
Commit: c8f337c0857686eab64236245f642a1e028e0ca4
Parents: ab7e51f
Author: zhouxh <gzhou@pivotal.io>
Authored: Thu May 11 11:33:12 2017 -0700
Committer: zhouxh <gzhou@pivotal.io>
Committed: Thu May 11 11:33:34 2017 -0700

----------------------------------------------------------------------
 geode-lucene/build.gradle                       |  2 ++
 .../lucene/LuceneQueriesIntegrationTest.java    | 32 ++++++++++++++++++++
 gradle/dependency-versions.properties           |  1 +
 3 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/c8f337c0/geode-lucene/build.gradle
----------------------------------------------------------------------
diff --git a/geode-lucene/build.gradle b/geode-lucene/build.gradle
index 8545200..74de7a6 100644
--- a/geode-lucene/build.gradle
+++ b/geode-lucene/build.gradle
@@ -32,6 +32,8 @@ dependencies {
     testCompile 'org.apache.lucene:lucene-test-framework:' + project.'lucene.version'
     testCompile 'org.apache.lucene:lucene-codecs:' + project.'lucene.version'
     testCompile 'com.pholser:junit-quickcheck-core:' + project.'junit-quickcheck.version'
+    testCompile 'org.apache.lucene:lucene-analyzers-phonetic:' + project.'lucene.version'
+    testCompile 'commons-codec:commons-codec:' + project.'codec.version'
     testCompile 'com.pholser:junit-quickcheck-generators:' + project.'junit-quickcheck.version'
     testCompile files(project(':geode-core').sourceSets.test.output)
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c8f337c0/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 9db0a5e..685d61c 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
@@ -34,7 +34,9 @@ import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Tokenizer;
 import org.apache.lucene.analysis.core.KeywordAnalyzer;
 import org.apache.lucene.analysis.core.LowerCaseFilter;
+import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.analysis.standard.StandardTokenizer;
 import org.apache.lucene.analysis.util.CharTokenizer;
 import org.junit.Ignore;
 import org.junit.Rule;
@@ -455,6 +457,27 @@ public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest
{
 
   }
 
+  @Test()
+  public void soundexQueryReturnExpectedTruePositiveAndFalsePositive() throws Exception {
+    Map<String, Analyzer> fields = new HashMap<String, Analyzer>();
+    fields.put("field1", new DoubleMetaphoneAnalyzer());
+    fields.put("field2", null);
+    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);
+
+    region.put("A", new TestObject("Stefan", "soundex"));
+    region.put("B", new TestObject("Steph", "soundex"));
+    region.put("C", new TestObject("Stephen", "soundex"));
+    region.put("D", new TestObject("Steve", "soundex"));
+    region.put("E", new TestObject("Steven", "soundex"));
+    region.put("F", new TestObject("Stove", "soundex"));
+    region.put("G", new TestObject("Stuffin", "soundex"));
+    luceneService.waitUntilFlushed(INDEX_NAME, REGION_NAME, 60000, TimeUnit.MILLISECONDS);
+
+    verifyQuery("field1:Stephen", DEFAULT_FIELD, "A", "C", "E", "G");
+  }
+
   private PdxInstance insertAJson(Region region, String key) {
     String jsonCustomer = "{" + "\"name\": \"" + key + "\"," + "\"lastName\": \"Smith\","
         + " \"age\": 25," + "\"address\":" + "{" + "\"streetAddress\": \"21 2nd Street\","
@@ -507,4 +530,13 @@ public class LuceneQueriesIntegrationTest extends LuceneIntegrationTest
{
       return new TokenStreamComponents(tokenizer, filter);
     }
   }
+
+  private static class DoubleMetaphoneAnalyzer extends Analyzer {
+    @Override
+    protected TokenStreamComponents createComponents(final String field) {
+      Tokenizer tokenizer = new StandardTokenizer();
+      TokenStream stream = new DoubleMetaphoneFilter(tokenizer, 6, false);
+      return new TokenStreamComponents(tokenizer, stream);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/geode/blob/c8f337c0/gradle/dependency-versions.properties
----------------------------------------------------------------------
diff --git a/gradle/dependency-versions.properties b/gradle/dependency-versions.properties
index a9e3fdf..98deadc 100644
--- a/gradle/dependency-versions.properties
+++ b/gradle/dependency-versions.properties
@@ -65,6 +65,7 @@ junit-quickcheck.version = 0.7
 JUnitParams.version = 1.0.6
 log4j.version = 2.7
 lucene.version = 6.4.1
+codec.version = 1.10
 mockito-core.version = 1.10.19
 mockrunner.version = 1.1.2
 mortbay-jetty-servlet-api.version=3.0.20100224


Mime
View raw message