Skip to content

Commit

Permalink
Add tests for synonym token filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippus committed May 11, 2024
1 parent b7275a2 commit 9cfae84
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "synonym_graph",
"synonyms_path": "analysis/synonyms.txt",
"format": "solr",
"ignore_case": true,
"updateable": true,
"expand": true,
"lenient": true,
"tokenizer": "whitespace"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "synonym_graph",
"synonyms": [
"british,english",
"queen,monarch"
],
"format": "solr",
"ignore_case": true,
"updateable": true,
"expand": true,
"lenient": true,
"tokenizer": "whitespace"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "synonym",
"synonyms_path": "analysis/synonyms.txt",
"format": "solr",
"ignore_case": true,
"updateable": true,
"expand": true,
"lenient": true,
"tokenizer": "whitespace"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "synonym",
"synonyms": [
"british,english",
"queen,monarch"
],
"format": "solr",
"ignore_case": true,
"updateable": true,
"expand": true,
"lenient": true,
"tokenizer": "whitespace"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,64 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

class TokenFilterTest extends AnyWordSpec with Matchers with JsonSugar {
"SynonymTokenFilter" should {
"build json with synonyms" in {
SynonymTokenFilter(
name = "my_synonym",
path = Option("analysis/synonyms.txt"),
synonyms = Set("british,english", "queen,monarch"),
ignoreCase = Option(true),
format = Option("solr"),
expand = Option(true),
tokenizer = Option("whitespace"),
updateable = Option(true),
lenient = Option(true)
).build.string should matchJsonResource("/json/analysis/tokenfilter/synonymtokenfilter_synonyms_raw.json")
}

"build json with path" in {
SynonymTokenFilter(
name = "my_synonym",
path = Option("analysis/synonyms.txt"),
ignoreCase = Option(true),
format = Option("solr"),
expand = Option(true),
tokenizer = Option("whitespace"),
updateable = Option(true),
lenient = Option(true)
).build.string should matchJsonResource("/json/analysis/tokenfilter/synonymtokenfilter_path_raw.json")
}
}

"SynonymGraphTokenFilter" should {
"build json with synonyms" in {
SynonymGraphTokenFilter(
name = "my_synonym",
path = Option("analysis/synonyms.txt"),
synonyms = Set("british,english", "queen,monarch"),
ignoreCase = Option(true),
format = Option("solr"),
expand = Option(true),
tokenizer = Option("whitespace"),
updateable = Option(true),
lenient = Option(true)
).build.string should matchJsonResource("/json/analysis/tokenfilter/synonymgraphtokenfilter_synonyms_raw.json")
}

"build json with path" in {
SynonymGraphTokenFilter(
name = "my_synonym",
path = Option("analysis/synonyms.txt"),
ignoreCase = Option(true),
format = Option("solr"),
expand = Option(true),
tokenizer = Option("whitespace"),
updateable = Option(true),
lenient = Option(true)
).build.string should matchJsonResource("/json/analysis/tokenfilter/synonymgraphtokenfilter_path_raw.json")
}
}

"WordDelimiterGraphTokenFilter" should {
"build json" in {
WordDelimiterGraphTokenFilter(
Expand Down

0 comments on commit 9cfae84

Please sign in to comment.