Complete the code to insert a document into Elasticsearch.
POST /my_index/_doc/[1] { "user": "alice", "message": "Hello Elasticsearch" }
The number 1 is the document ID used to insert the document into the index.
Complete the code to query documents containing the word 'error'.
GET /logs/_search
{
"query": {
"match": {
"message": "[1]"
}
}
}The query searches for documents where the message field contains the word error.
Fix the error in the pipeline configuration to send data to Elasticsearch.
output {
elasticsearch {
hosts => ["[1]"]
index => "logs-%{+YYYY.MM.dd}"
}
}The hosts setting requires the full URL including the protocol, like http://localhost:9200.
Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.
{word: [1] for word in words if [2]The comprehension maps each word to its length using len(word) and filters words with length greater than 3 using len(word) > 3.
Fill all three blanks to create a filtered dictionary from data where keys are uppercase and values are positive.
{ [1]: [2] for [3], v in data.items() if v > 0 }The dictionary comprehension uses k.upper() as keys, v as values, and iterates over k, v pairs from data.items().