From eacbf31a6b8b3035745c9db1fbfe0486ccc6f1c1 Mon Sep 17 00:00:00 2001 From: Robert Newson Date: Mon, 7 Nov 2022 16:57:19 +0000 Subject: [PATCH] Revert "Return no analyzer when perfield field is not valid (#51)" This reverts commit d33cf1c26574341cf019b6cc698ecb6c4fdab55d. --- .../scala/com/cloudant/clouseau/SupportedAnalyzers.scala | 4 ++-- .../com/cloudant/clouseau/SupportedAnalyzersSpec.scala | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/com/cloudant/clouseau/SupportedAnalyzers.scala b/src/main/scala/com/cloudant/clouseau/SupportedAnalyzers.scala index c5393ea9..d4514898 100644 --- a/src/main/scala/com/cloudant/clouseau/SupportedAnalyzers.scala +++ b/src/main/scala/com/cloudant/clouseau/SupportedAnalyzers.scala @@ -100,7 +100,7 @@ object SupportedAnalyzers { map.get("name") match { case Some(name: String) => createAnalyzerInt(name, map) - case _ => + case None => None } case _ => @@ -379,7 +379,7 @@ object SupportedAnalyzers { case Some(fieldAnalyzer) => (kv._1, fieldAnalyzer) case None => - throw new IllegalArgumentException("no_such_analyzer") + (kv._1, defaultAnalyzer) } } toMap case _ => diff --git a/src/test/scala/com/cloudant/clouseau/SupportedAnalyzersSpec.scala b/src/test/scala/com/cloudant/clouseau/SupportedAnalyzersSpec.scala index ca349267..87c6d099 100644 --- a/src/test/scala/com/cloudant/clouseau/SupportedAnalyzersSpec.scala +++ b/src/test/scala/com/cloudant/clouseau/SupportedAnalyzersSpec.scala @@ -93,9 +93,9 @@ class SupportedAnalyzersSpec extends SpecificationWithJUnit { createAnalyzer(Map("name" -> "perfield", "fields" -> List("foo" -> "english"))).toString must contain("foo -> org.apache.lucene.analysis.en.EnglishAnalyzer") - // unrecognized per-field throws an IllegalArgumentException("no_such_analyzer") - createAnalyzer(Map("name" -> "perfield", "default" -> "english", "fields" -> List("foo" -> "foo"))) must - throwAn[IllegalArgumentException] + // unrecognized per-field becomes default + createAnalyzer(Map("name" -> "perfield", "default" -> "english", "fields" -> List("foo" -> "foo"))).toString must + contain("foo -> org.apache.lucene.analysis.en.EnglishAnalyzer") } "arabic" in { createAnalyzer("arabic") must haveClass[Some[ArabicAnalyzer]]