Complete the code to perform a basic search query in Elasticsearch.
GET /my_index/_search
{
"query": {
"match": {
"message": "[1]"
}
}
}The match query searches for the term Elasticsearch in the message field.
Complete the code to filter search results by a specific field value.
GET /my_index/_search
{
"query": {
"bool": {
"filter": {
"term": { "status": "[1]" }
}
}
}
}The term filter restricts results to documents where status is active.
Fix the error in the search query to correctly match documents containing the word 'fast'.
GET /my_index/_search
{
"query": {
"match": {
"description": "[1]"
}
}
}The match query should use the exact word fast to find matching documents.
Fill both blanks to create a search query that matches documents where the 'title' contains 'Elasticsearch' and the 'published' field is true.
GET /my_index/_search
{
"query": {
"bool": {
"must": {
"match": { "title": "[1]" }
},
"filter": {
"term": { "published": [2] }
}
}
}
}The match query searches for 'Elasticsearch' in the title, and the term filter ensures only published documents (true) are returned.
Fill all three blanks to create a search query that returns documents where the 'content' field contains 'fast', the 'views' field is greater than 100, and results are sorted by 'date' descending.
GET /my_index/_search
{
"query": {
"bool": {
"must": {
"match": { "content": "[1]" }
},
"filter": {
"range": { "views": { "[2]": [3] } }
}
}
},
"sort": [ { "date": "desc" } ]
}The match query looks for 'fast' in content, the range filter uses 'gt' (greater than) 100 for views, and results are sorted by date descending.