geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [11/43] geode git commit: GEODE-2957: Lucene create index DEFAULT keyword added for standardAnalyzer
Date Tue, 30 May 2017 17:42:03 GMT
GEODE-2957: Lucene create index DEFAULT keyword added for standardAnalyzer

	This closes #537


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

Branch: refs/heads/feature/GEODE-2632-17
Commit: 29ea88a23ef0feb29e8d7684c4061ac54dc66874
Parents: 5ab4a69
Author: David Anuta <david.r.anuta@gmail.com>
Authored: Thu May 25 13:45:23 2017 -0700
Committer: nabarun <nnag@pivotal.io>
Committed: Thu May 25 16:54:25 2017 -0700

----------------------------------------------------------------------
 .../functions/LuceneCreateIndexFunction.java    |  2 +-
 .../cli/LuceneIndexCommandsDUnitTest.java       | 68 +++++++++++++++++---
 2 files changed, 59 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/29ea88a2/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
index d49f7f9..5e36efa 100644
--- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
+++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/functions/LuceneCreateIndexFunction.java
@@ -105,7 +105,7 @@ public class LuceneCreateIndexFunction extends FunctionAdapter implements
Intern
       className = StandardAnalyzer.class.getCanonicalName();
     else {
       String trimmedClassName = StringUtils.trim(className);
-      if (trimmedClassName.equals("") || trimmedClassName.equals("null"))
+      if (trimmedClassName.equals("") || trimmedClassName.equals("DEFAULT"))
         className = StandardAnalyzer.class.getCanonicalName();
       else
         className = trimmedClassName;

http://git-wip-us.apache.org/repos/asf/geode/blob/29ea88a2/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
index 5cbe31c..009c74c 100755
--- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
+++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
@@ -298,33 +298,81 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase
{
   }
 
   @Test
-  public void createIndexWithNullAnalyzerShouldUseStandardAnalyzer() throws Exception {
-    final VM vm1 = Host.getHost(0).getVM(1);
+  public void createIndexWithWhitespaceOrDefaultKeywordAnalyzerShouldUseStandardAnalyzer()
+      throws Exception {
+    final VM vm1 = Host.getHost(0).getVM(-1);
     vm1.invoke(() -> {
       getCache();
     });
 
-    String analyzerList = StandardAnalyzer.class.getCanonicalName() + ",null,"
+    // Test whitespace analyzer name
+    String analyzerList = StandardAnalyzer.class.getCanonicalName() + ",     ,"
         + KeywordAnalyzer.class.getCanonicalName();
     CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
-    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "space");
     csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
     csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
-    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, analyzerList);
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, "'" + analyzerList + "'");
 
     String resultAsString = executeCommandAndLogResult(csb);
 
+    // Test empty analyzer name
+    analyzerList =
+        StandardAnalyzer.class.getCanonicalName() + ",," + KeywordAnalyzer.class.getCanonicalName();
+    csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "empty");
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, analyzerList);
+
+    resultAsString = executeCommandAndLogResult(csb);
+
+    // Test keyword analyzer name
+    analyzerList = StandardAnalyzer.class.getCanonicalName() + ",DEFAULT,"
+        + KeywordAnalyzer.class.getCanonicalName();
+    csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
+    csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "keyword");
+    csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
+    csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, analyzerList);
+
+    resultAsString = executeCommandAndLogResult(csb);
+
     vm1.invoke(() -> {
       LuceneService luceneService = LuceneServiceProvider.get(getCache());
       createRegion();
-      final LuceneIndex index = luceneService.getIndex(INDEX_NAME, REGION_NAME);
-      final Map<String, Analyzer> fieldAnalyzers = index.getFieldAnalyzers();
+      final LuceneIndex spaceIndex = luceneService.getIndex("space", REGION_NAME);
+      final Map<String, Analyzer> spaceFieldAnalyzers = spaceIndex.getFieldAnalyzers();
+
+      final LuceneIndex emptyIndex = luceneService.getIndex("empty", REGION_NAME);
+      final Map<String, Analyzer> emptyFieldAnalyzers2 = emptyIndex.getFieldAnalyzers();
+
+      final LuceneIndex keywordIndex = luceneService.getIndex("keyword", REGION_NAME);
+      final Map<String, Analyzer> keywordFieldAnalyzers = keywordIndex.getFieldAnalyzers();
+
+      // Test whitespace analyzers
+      assertEquals(StandardAnalyzer.class.getCanonicalName(),
+          spaceFieldAnalyzers.get("field1").getClass().getCanonicalName());
+      assertEquals(StandardAnalyzer.class.getCanonicalName(),
+          spaceFieldAnalyzers.get("field2").getClass().getCanonicalName());
+      assertEquals(KeywordAnalyzer.class.getCanonicalName(),
+          spaceFieldAnalyzers.get("field3").getClass().getCanonicalName());
+
+      // Test empty analyzers
+      assertEquals(StandardAnalyzer.class.getCanonicalName(),
+          emptyFieldAnalyzers2.get("field1").getClass().getCanonicalName());
+      assertEquals(StandardAnalyzer.class.getCanonicalName(),
+          emptyFieldAnalyzers2.get("field2").getClass().getCanonicalName());
+      assertEquals(KeywordAnalyzer.class.getCanonicalName(),
+          emptyFieldAnalyzers2.get("field3").getClass().getCanonicalName());
+
+      // Test keyword analyzers
       assertEquals(StandardAnalyzer.class.getCanonicalName(),
-          fieldAnalyzers.get("field1").getClass().getCanonicalName());
+          keywordFieldAnalyzers.get("field1").getClass().getCanonicalName());
       assertEquals(StandardAnalyzer.class.getCanonicalName(),
-          fieldAnalyzers.get("field2").getClass().getCanonicalName());
+          keywordFieldAnalyzers.get("field2").getClass().getCanonicalName());
       assertEquals(KeywordAnalyzer.class.getCanonicalName(),
-          fieldAnalyzers.get("field3").getClass().getCanonicalName());
+          keywordFieldAnalyzers.get("field3").getClass().getCanonicalName());
     });
   }
 


Mime
View raw message