0
0
Elasticsearchquery~20 mins

Synonym handling in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Synonym Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this synonym filter configuration?
Given the following Elasticsearch analyzer configuration with synonyms, what tokens will be produced for the input text "quick fox"?
Elasticsearch
{
  "settings": {
    "analysis": {
      "filter": {
        "synonym_filter": {
          "type": "synonym",
          "synonyms": [
            "quick,fast",
            "fox,red fox"
          ]
        }
      },
      "analyzer": {
        "synonym_analyzer": {
          "tokenizer": "standard",
          "filter": ["lowercase", "synonym_filter"]
        }
      }
    }
  }
}

Input text: "quick fox"
A["quick", "fast", "fox", "red", "fox"]
B["quick", "fox"]
C["fast", "red", "fox"]
D["quick", "fast", "fox"]
Attempts:
2 left
💡 Hint
Think about how synonyms expand tokens during analysis.
🧠 Conceptual
intermediate
1:30remaining
Which synonym type supports multi-word synonyms in Elasticsearch?
Elasticsearch supports different synonym types. Which synonym type allows you to define multi-word synonyms like "red fox" as a synonym for "fox"?
A"synonym_graph" filter
B"synonym" filter with <code>expand: true</code>
C"stop" filter
D"keyword" filter
Attempts:
2 left
💡 Hint
Multi-word synonyms require special handling to preserve token positions.
🔧 Debug
advanced
2:00remaining
Why does this synonym filter cause a query parsing error?
Given this synonym filter snippet, why does Elasticsearch return a parsing error when indexing documents? "synonyms": [ "fast, quick", "fox => red fox" ]
Elasticsearch
synonyms: [
  "fast, quick",
  "fox => red fox"
]
AThe arrow syntax (=>) is only valid in the "synonym" filter, but the list is missing commas.
BThe arrow syntax (=>) is invalid in the "synonym" filter; it requires the "synonym" filter with <code>expand: false</code>.
CThe arrow syntax (=>) is valid only if <code>expand</code> is set to false, which is missing here.
DThe arrow syntax (=>) is invalid in the "synonym" filter; it requires the "synonym_graph" filter.
Attempts:
2 left
💡 Hint
Check the rules for using arrow syntax in synonym filters.
📝 Syntax
advanced
2:00remaining
Which synonym filter configuration is syntactically correct for multi-word synonyms?
Select the correct Elasticsearch synonym filter configuration snippet that supports multi-word synonyms without errors.
A
{
  "type": "synonym",
  "synonyms": ["red fox, fox"]
}
B
{
  "type": "synonym_graph",
  "synonyms": ["red fox, fox"]
}
C
{
  "type": "synonym",
  "synonyms": ["red fox =&gt; fox"]
}
D
{
  "type": "synonym_graph",
  "synonyms": ["red fox =&gt; fox"]
}
Attempts:
2 left
💡 Hint
Multi-word synonyms with arrow syntax require a specific filter type.
🚀 Application
expert
2:30remaining
How many tokens are produced by this analyzer with synonyms and stop words?
Given this analyzer configuration and input text, how many tokens are produced? Analyzer config: { "tokenizer": "standard", "filter": ["lowercase", "stop_filter", "synonym_filter"] } Filters: - stop_filter removes: "the", "a" - synonym_filter synonyms: "quick,fast" "fox,red fox" Input text: "The quick brown fox jumps over a lazy dog"
A11
B9
C10
D12
Attempts:
2 left
💡 Hint
Count tokens after stop word removal and synonym expansion.