0
0
Elasticsearchquery~5 mins

Highlighting matched text in Elasticsearch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of highlighting in Elasticsearch search results?
Highlighting shows the parts of the text that match the search query, making it easier to see why a document was found.
Click to reveal answer
beginner
Which Elasticsearch query section is used to add highlighting to search results?
The highlight section is added alongside the query in the search request to specify which fields to highlight.
Click to reveal answer
intermediate
What does the pre_tags and post_tags in Elasticsearch highlighting do?
They define the HTML or text tags that wrap around the matched text to visually mark it, for example, <em> and </em>.
Click to reveal answer
beginner
How do you specify which fields to highlight in an Elasticsearch query?
Inside the highlight section, use the fields object with field names as keys and empty objects or options as values.
Click to reveal answer
intermediate
What is the default behavior if you do not specify pre_tags and post_tags in Elasticsearch highlighting?
Elasticsearch wraps matched text with <em> and </em> tags by default.
Click to reveal answer
In Elasticsearch, where do you add the highlighting instructions in a search request?
AInside the <code>highlight</code> section alongside the <code>query</code>
BInside the <code>filter</code> section
CInside the <code>sort</code> section
DInside the <code>aggs</code> section
What tags does Elasticsearch use by default to wrap highlighted text?
A<code>&lt;strong&gt;</code> and <code>&lt;/strong&gt;</code>
B<code>&lt;mark&gt;</code> and <code>&lt;/mark&gt;</code>
C<code>&lt;highlight&gt;</code> and <code>&lt;/highlight&gt;</code>
D<code>&lt;em&gt;</code> and <code>&lt;/em&gt;</code>
How do you specify multiple fields to highlight in Elasticsearch?
AList them as an array under <code>fields</code>
BUse a comma-separated string in <code>fields</code>
CAdd each field as a key inside <code>fields</code> with an empty object as value
DHighlighting only works on one field at a time
What is the effect of setting number_of_fragments to 0 in highlighting?
ANo fragments are returned
BThe whole field content is returned as one fragment
COnly the first fragment is returned
DFragments are returned with default size
Which of these is NOT a valid use of the highlight section in Elasticsearch?
ASort search results by relevance
BCustomize tags wrapping matched text
CControl fragment size and number
DSpecify fields to highlight
Explain how to add highlighting to an Elasticsearch search query and customize the tags used to mark matched text.
Think about where you put the highlight instructions and how to change the default <em> tags.
You got /3 concepts.
    Describe the default behavior of Elasticsearch highlighting and how it helps users understand search results.
    Focus on what the user sees and why highlighting is useful.
    You got /3 concepts.