0
0
Elasticsearchquery~20 mins

Completion suggester in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Completion Suggester Master
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 completion suggester query?

Given the following Elasticsearch completion suggester query, what will be the returned suggestion text?

Elasticsearch
{
  "suggest": {
    "song-suggest": {
      "prefix": "lov",
      "completion": {
        "field": "suggest",
        "size": 1
      }
    }
  }
}
A["love story"]
B["lovely day"]
C[]
D["lover boy"]
Attempts:
2 left
💡 Hint

Check the indexed suggestions that start with the prefix "lov".

🧠 Conceptual
intermediate
1:30remaining
Which field type is required for using completion suggester?

To use the completion suggester in Elasticsearch, which field mapping type must be used?

A"keyword"
B"text"
C"completion"
D"nested"
Attempts:
2 left
💡 Hint

Look for the specialized field type designed for fast prefix suggestions.

🔧 Debug
advanced
2:30remaining
Why does this completion suggester query return no suggestions?

Consider this query that returns no suggestions despite data being indexed:

{
  "suggest": {
    "user-suggest": {
      "prefix": "jo",
      "completion": {
        "field": "user_suggest",
        "skip_duplicates": true
      }
    }
  }
}

What is the most likely cause?

AThe prefix "jo" is too short for suggestions.
BThe "skip_duplicates" parameter disables all suggestions.
CThe query syntax is invalid and causes an error.
DThe field "user_suggest" is not mapped as "completion" type.
Attempts:
2 left
💡 Hint

Check the field mapping type for "user_suggest".

📝 Syntax
advanced
2:30remaining
Which option correctly uses the completion suggester with contexts?

Which of the following JSON queries correctly uses a context filter in a completion suggester?

A
{
  "suggest": {
    "product-suggest": {
      "prefix": "iph",
      "completion": {
        "field": "product_suggest",
        "contexts": {
          "category": "smartphones"
        }
      }
    }
  }
}
B
{
  "suggest": {
    "product-suggest": {
      "prefix": "iph",
      "completion": {
        "field": "product_suggest",
        "contexts": {
          "category": ["smartphones"]
        }
      }
    }
  }
}
C
{
  "suggest": {
    "product-suggest": {
      "prefix": "iph",
      "completion": {
        "field": "product_suggest",
        "contexts": [
          {"category": "smartphones"}
        ]
      }
    }
  }
}
D
{
  "suggest": {
    "product-suggest": {
      "prefix": "iph",
      "completion": {
        "field": "product_suggest",
        "context": {
          "category": ["smartphones"]
        }
      }
    }
  }
}
Attempts:
2 left
💡 Hint

Check the correct key name and value type for contexts in completion suggester.

🚀 Application
expert
2:00remaining
How many suggestions will this completion suggester return?

Given this query:

{
  "suggest": {
    "city-suggest": {
      "prefix": "new",
      "completion": {
        "field": "city_suggest",
        "size": 3
      }
    }
  }
}

And the indexed suggestions are: "new york", "newark", "new orleans", "newcastle", "newport". How many suggestions will be returned?

A3
B5
C1
D0
Attempts:
2 left
💡 Hint

Look at the "size" parameter in the query.