Synonym handling in Elasticsearch means telling the search engine that some words mean the same. This helps find more results even if the exact word isn't used.
Click to reveal answer
beginner
How do you define synonyms in Elasticsearch?
You define synonyms by creating a synonym filter in the analyzer settings. You list words or phrases that should be treated as equal, separated by commas or arrows (=>).
Click to reveal answer
intermediate
What is the difference between 'synonym' and 'synonym_graph' filters?
'synonym' filter works well for indexing but can cause issues with phrase queries. 'synonym_graph' is better for search time and phrase queries because it handles word positions correctly.
Click to reveal answer
intermediate
Why is it important to apply synonyms at search time rather than index time?
Applying synonyms at search time keeps the index smaller and more efficient. It also allows changing synonyms without reindexing all data.
Click to reveal answer
beginner
Give an example of a synonym rule in Elasticsearch.
Example: "car, automobile, vehicle" means these words are treated the same. Another example: "usa, united states, america" means all these refer to the same concept.
Click to reveal answer
What does a synonym filter do in Elasticsearch?
ADeletes duplicate documents
BTreats listed words as equal during search or indexing
CSorts search results alphabetically
DEncrypts the search data
✗ Incorrect
A synonym filter makes Elasticsearch treat certain words as the same to improve search results.
Which synonym filter is better for phrase queries?
Asynonym_graph
Bsynonym
Cstop
Dlowercase
✗ Incorrect
The synonym_graph filter handles word positions properly, making it better for phrase queries.
Where is it recommended to apply synonyms for flexibility?
AIn the database
BAt index time
CIn the client application
DAt search time
✗ Incorrect
Applying synonyms at search time allows changing them without reindexing data.
How are synonyms usually listed in the filter?
AAs XML tags
BIn JSON arrays
CSeparated by commas or arrows
DIn SQL tables
✗ Incorrect
Synonyms are listed as comma-separated or arrow-separated words or phrases.
What is a benefit of using synonym handling?
AFinds more relevant search results
BSpeeds up indexing
CReduces disk space
DPrevents spelling mistakes
✗ Incorrect
Synonym handling helps find more relevant results by matching similar words.
Explain how to set up synonym handling in Elasticsearch and why it is useful.
Think about how you tell Elasticsearch that some words mean the same.
You got /4 concepts.
Describe the difference between applying synonyms at index time versus search time.
Consider when the synonym rules are applied and how it affects the data.
You got /5 concepts.
Practice
(1/5)
1. What is the main purpose of synonym handling in Elasticsearch?
easy
A. To find search results that include different words with the same meaning
B. To speed up the indexing process
C. To store data in multiple languages automatically
D. To encrypt search queries for security
Solution
Step 1: Understand synonym handling concept
Synonym handling allows Elasticsearch to match words that mean the same, improving search results.
Step 2: Identify the main goal
The goal is to find results with different words but same meaning, not speed or encryption.
Final Answer:
To find search results that include different words with the same meaning -> Option A
Quick Check:
Synonym handling = find similar meaning words [OK]
Hint: Synonyms help find words with same meaning [OK]
Common Mistakes:
Thinking synonyms speed up indexing
Confusing synonyms with encryption
Assuming synonyms translate languages automatically
2. Which of the following is the correct way to define a synonym filter in Elasticsearch settings?
The synonym filter maps "fast" to "quick", so both tokens appear for "fast".
Step 2: List all tokens after analysis
Tokens are "fast", "quick" (synonym), and "car" (unchanged).
Final Answer:
["fast", "quick", "car"] -> Option B
Quick Check:
Synonym adds "quick" token for "fast" [OK]
Hint: Synonym filter adds synonyms as extra tokens [OK]
Common Mistakes:
Ignoring synonym addition and listing only original tokens
Replacing original token instead of adding synonym
Duplicating tokens unnecessarily
4. You defined a synonym filter but your search results do not include synonyms. What is the most likely mistake?
medium
A. You used the synonym filter in the index but not in the search analyzer
B. You forgot to add the synonym filter to the analyzer's filter list
C. You defined synonyms as a string instead of a list
D. You used the synonym filter with the wrong tokenizer
Solution
Step 1: Understand how synonym filters affect search
Synonyms must be applied in the analyzer used during search to affect results.
Step 2: Identify common setup mistake
Often synonyms are applied only at index time, missing search analyzer usage.
Final Answer:
You used the synonym filter in the index but not in the search analyzer -> Option A
Quick Check:
Synonyms must be in search analyzer too [OK]
Hint: Apply synonym filter in both index and search analyzers [OK]
Common Mistakes:
Adding synonym filter only at index time
Not including synonym filter in search analyzer
Misconfiguring synonyms as string instead of list
5. You want to improve search for a product catalog where users may search for "tv", "television", or "smart tv". How should you configure synonyms to handle these terms effectively?
hard
A. Apply synonyms only at search time to avoid changing indexed data
B. Define synonyms only for "tv" and "television" but exclude "smart tv" because it has two words
C. Use a stop filter to remove "smart" and then define synonyms for "tv" and "television"
D. Define synonyms as: "tv, television, smart tv" in a synonym filter and apply it in both index and search analyzers
Solution
Step 1: Define all related terms as synonyms
Include "tv", "television", and "smart tv" together to cover all user queries.
Step 2: Apply synonym filter in both index and search analyzers
This ensures synonyms work during indexing and searching for best results.
Final Answer:
Define synonyms as: "tv, television, smart tv" in a synonym filter and apply it in both index and search analyzers -> Option D
Quick Check:
Synonyms cover all terms and apply at both stages [OK]
Hint: Include all terms and apply synonyms at index and search [OK]
Common Mistakes:
Ignoring multi-word synonyms like "smart tv"
Applying synonyms only at search time
Using stop filter incorrectly to remove words
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.